Created
April 3, 2017 16:52
-
-
Save dragthor/3b47221fabbca0e04f1a4df8802e91a5 to your computer and use it in GitHub Desktop.
Zurb Blink Plugin Js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
!function ($) { | |
class Blink { | |
constructor(element, options) { | |
this.$element = element; | |
this.options = $.extend({}, Blink.defaults, this.$element.data(), options); | |
this.timer = 0; | |
this._init(); | |
Foundation.registerPlugin(this, 'Blink'); | |
} | |
_init() { | |
this._events(); | |
this.start(); | |
} | |
_events() { /* None at this time. */ } | |
start() { | |
if (this.timer > 0) return; // Already started. | |
var blink = this.$element; | |
this.timer = setInterval(function () { | |
if (blink.hasClass('active')) { | |
blink.css('visibility', 'hidden'); | |
blink.removeClass('active'); | |
} else { | |
blink.css('visibility', 'visible'); | |
blink.addClass('active'); | |
} | |
}, this.options.interval); | |
} | |
stop() { | |
clearTimeout(this.timer); | |
this.timer = 0; | |
} | |
destroy() { | |
clearTimeout(this.timer); | |
Foundation.unregisterPlugin(this); | |
} | |
} | |
Blink.defaults = { | |
interval: 500 | |
}; | |
// Window exports | |
Foundation.plugin(Blink, 'Blink'); | |
}(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment