gitlab-org--gitlab-foss/app/assets/javascripts/logo.js.coffee
Aaron Hamilton 9eba0eaac3 Prevent rasterization artefacts in the logo, and simplify markup.
- Remove sketch-namespaced attributes.
 - Remove unused groups, and cancel out unnecessary transforms.
 - Use overlap to avoid rasterization artefacts in the logo.
 - Extend comment for `#logo` click event handler, as it's a non-obvious hack for Safari.
 - Remove viewBox parameter and define paths in their final form.
2016-02-08 04:25:50 +00:00

50 lines
1.2 KiB
CoffeeScript

NProgress.configure(showSpinner: false)
defaultClass = 'tanuki-shape'
pieces = [
'path#tanuki-right-cheek',
'path#tanuki-right-eye, path#tanuki-right-ear',
'path#tanuki-nose',
'path#tanuki-left-eye, path#tanuki-left-ear',
'path#tanuki-left-cheek',
]
pieceIndex = 0
firstPiece = pieces[0]
currentTimer = null
delay = 150
clearHighlights = ->
$(".#{defaultClass}.highlight").attr('class', defaultClass)
start = ->
clearHighlights()
pieceIndex = 0
pieces.reverse() unless pieces[0] == firstPiece
clearInterval(currentTimer) if currentTimer
currentTimer = setInterval(work, delay)
stop = ->
clearInterval(currentTimer)
clearHighlights()
work = ->
clearHighlights()
$(pieces[pieceIndex]).attr('class', "#{defaultClass} highlight")
# If we hit the last piece, reset the index and then reverse the array to
# get a nice back-and-forth sweeping look
if pieceIndex == pieces.length - 1
pieceIndex = 0
pieces.reverse()
else
pieceIndex++
$(document).on('page:fetch', start)
$(document).on('page:change', stop)
$ ->
# Make logo clickable as part of a workaround for Safari visited
# link behaviour (See !2690).
$('#logo').on 'click', ->
$('#js-shortcuts-home').get(0).click()