Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@
return getNumber(easing, start, end, ratio);
}

function CallbackParallax (element, callback) {
this.element = element;
this.callback = callback;
}

CallbackParallax.prototype.handleScroll = function (ratio, distance, watcher) {
this.callback(ratio, distance, watcher)
};

function OptionsParallax (element, options, container) {
container = container || scrollMonitor;
this.options = options;
Expand Down Expand Up @@ -144,12 +153,21 @@
var newItem;
if (typeof optionsOrSpeed === 'number') {
newItem = new SpeedParallax(element, optionsOrSpeed);
} else if (typeof optionsOrSpeed === 'function') {
newItem = new CallbackParallax(element, optionsOrSpeed);
} else {
newItem = new OptionsParallax(element, optionsOrSpeed, this.container);
}

this.items.push(newItem);
};

Root.prototype.destroy = function () {
if (this.watcher) {
this.items = []
this.watcher.destroy()
}
}

return {
create: function (item, offsets, container) {
Expand Down