-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loop function / Active Class #15
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
animation: "bounceIn", | ||
separator: ",", | ||
speed: 2000, | ||
activeClass: 'active', | ||
loop: 10, // loop n times around TBC | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if I'm keen on including an out-of-the-box support for a loop limit. Seems like something that can be achieved by the |
||
complete: $.noop | ||
}; | ||
|
||
|
@@ -36,22 +38,35 @@ | |
Plugin.prototype = { | ||
_init: function () { | ||
var $that = this; | ||
this.position = 0; | ||
this.loops = 0; | ||
this.phrases = []; | ||
|
||
this.element.addClass("morphext"); | ||
|
||
$.each(this.element.text().split(this.settings.separator), function (key, value) { | ||
$that.phrases.push($.trim(value)); | ||
|
||
}); | ||
|
||
this.loops = this.settings.loop * this.phrases.length; | ||
|
||
this.index = -1; | ||
this.animate(); | ||
this.start(); | ||
this.start(); | ||
|
||
}, | ||
animate: function () { | ||
this.position++; | ||
this.index = ++this.index % this.phrases.length; | ||
this.element[0].innerHTML = "<span class=\"animated " + this.settings.animation + "\">" + this.phrases[this.index] + "</span>"; | ||
this.element[0].classList.add(this.settings.activeClass); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if it's necessary for us to |
||
|
||
|
||
|
||
//console.log(this.position); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly want to remove the comment here. |
||
if(this.position == this.loops){ | ||
this.stop(); | ||
} | ||
if ($.isFunction(this.settings.complete)) { | ||
this.settings.complete.call(this); | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use double quotes here for consistency? I think with the new ESLint configuration, this should be caught.