Skip to content
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

ItemsComponentModel #179

Merged
merged 23 commits into from
Jun 26, 2018
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions js/narrativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ define([
this.checkIfResetOnRevisit();
this._isInitial = true;
this.calculateWidths();
_.bindAll(this, 'onTransitionEnd');
},

clamp: function(number, min, max) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function isn't needed

return Math.max(min, Math.min(number, max));
},

onItemsActiveChange: function(item, _isActive) {
Expand Down Expand Up @@ -177,15 +180,11 @@ define([
if (Adapt.config.get('_disableAnimation')) {
this.onTransitionEnd();
} else {
$sliderElm.on('transitionend', this.onTransitionEnd);
$sliderElm.one('transitionend', this.onTransitionEnd.bind(this));
}
},

onTransitionEnd: function(event) {
if (event) {
$(event.currentTarget).off('transitionend', this.onTransitionEnd);
}

var index = this.model.getActiveItem().get('_index');
if (this.model.get('_isDesktop')) {
if (!this._isInitial) {
Expand Down Expand Up @@ -265,13 +264,11 @@ define([
var numberOfItems = this.model.get('_children').length;

if ($(event.currentTarget).hasClass('narrative-control-right')) {
stage++;
this.model.setActiveItem(stage);
this.model.setActiveItem(stage+=1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you change to this.model.setActiveItem(++stage);? the pre-increment operator is pretty standard JS

} else if ($(event.currentTarget).hasClass('narrative-control-left')) {
stage--;
this.model.setActiveItem(stage);
this.model.setActiveItem(stage-=1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you change to this.model.setActiveItem(--stage);? the pre-decrement operator is pretty standard JS

}
stage = (stage + numberOfItems) % numberOfItems;
stage = this.clamp(stage, 0, numberOfItems);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really think you can delete this line as stage is a local variable and this is the last line of the function

},

onProgressClicked: function(event) {
Expand Down Expand Up @@ -301,7 +298,7 @@ define([

setupEventListeners: function() {
if (this.model.get('_setCompletionOn') === 'inview') {
this.$('.component-widget').on('inview', _.bind(this.inview, this));
this.$('.component-widget').on('inview', this.inview.bind(this));
}
},

Expand Down