8000 Release 1.0.2 by diervo · Pull Request #2 · forcedotcom/scrollerjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Release 1.0.2 8000 #2

Merged
merged 6 commits into from
Jul 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion examples/feed/example-ptr-ptl-plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ <h5 class="bg-3 pam mbm">Scroller Configuration</h5>
pullToLoadMore : true,
useCSSTransition: true,
lockOnDirection : 'horizontal',
gpuOptimization : true,
onPullToRefresh : ptr,
onPullToLoadMore: ptr,
scrollbars : false,
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/pull-to-load-more.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@
* ==================================
*/
getPTLSize: function () {
if (!this._ptlThreshold) {
this._ptlThreshold = this.ptlDOM.offsetHeight;
}

return this._ptlThreshold;
},
getPTLSnapTime: function () {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/zoom-fx-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

matrix.m42 = y; // sets initial y
matrix.m41 = x; // sets initial x
matrix.m33 = 0; // sets a z coord so is "matrix3d"
matrix.m33 = 1; // sets a z coord so is "matrix3d"

matrix = matrix.scale(normalizedPos);
//matrix = matrix.rotate(0,0, (2 * (3 + normalizedPos)), 0.01);
Expand Down
77 changes: 71 additions & 6 deletions src/scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@
*/
SCROLL_HORIZONTAL = 'horizontal',

/**
* Configuration object for the MutatorObserver
*
* @property MUTATOR_OBSERVER_CONFIG
* @type Object
* @static
* @final
*/
MUTATOR_OBSERVER_CONFIG = {
subtree : true,
childList : true,
attributes : false
// NOTE: if using attributeFilter
// Avoid listen for "style" attribute changes
},

/**
* Default configuration for the scroller.
* This option can be modified at the static level
Expand All @@ -114,7 +130,9 @@
scrollbars : false,
infiniteLoading : false,
gpuOptimization : false,
debounce : true
debounce : true,
observeDomChanges : true,
observeDomConfig : MUTATOR_OBSERVER_CONFIG
},

/**
Expand Down Expand Up @@ -292,6 +310,37 @@
}
},
/**
* Returns wether or not to obserChanges on the DOM
* By default `observeDomChanges` will be enabled
* unless `gpuOptimization` is set to true.
*
* @method _observeChanges
* @return {Boolean} Boolean to wether observe changes or not.
* @protected
*/
_observeChanges: function () {
return window.MutationObserver && this.opts.observeDomChanges && !this.opts.gpuOptimization;
},
/**
* Creates a MutationObserver object and
* sets it to observe the Scoller wrapper elelement.
*
* @method _initializeDOMObserver
* @private
*/
_initializeDOMObserver: function () {
var self = this,
config = this.opts.observeDomConfig,
observer = this.observer = new MutationObserver(function () {
self._observedDOMChange.apply(self, arguments);
});

observer.observe(this.wrapper, config);
},
_observedDOMChange: function (e) {
this.refresh();
},
/**
* Helper method to merge two object configurations.
* Relies on the `Helpers` utility module.
*
Expand Down Expand Up @@ -386,15 +435,14 @@
var scrollerDOM = this.scroller,
// We need to take into account if the `PullToLoadMore` plugin is active
// and in that case substract the height from the scrollable area size
ptl = this.opts.pullToLoadMore,
ptl_offset = this._ptlThreshold || 0;
ptl = this.opts.pullToLoadMore;

this._setWrapperSize();
this._sizePullToShowMore();

// Once all the sizes are accurate, performn the scroll size calculations
this.scrollerWidth = scrollerDOM.offsetWidth;
this.scrollerHeight = ptl ? scrollerDOM.offsetHeight - ptl_offset : scrollerDOM.offsetHeight;
this.scrollerHeight = ptl ? scrollerDOM.offsetHeight - this.getPTLSize() : scrollerDOM.offsetHeight;

this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
Expand All @@ -417,6 +465,18 @@
_sizePullToShowMore: function () {
//To be overriden
},
/**
* To be overriden by the `PullToShowMore` plugin.
* Gets the height of `PullToShowMore` so
* it can be taken into account when calculating the total scrollable size.
*
* @method getPTLSize
* @private
*/
getPTLSize: function () {
return 0;
},

/**
* Private destroy function that is responsible for the destruction of the
* instance itself.
Expand Down Expand Up @@ -491,6 +551,10 @@

eventType(this.scroller, 'transitionend', this);
eventType(this.scroller, SUPPORT.prefix + 'TransitionEnd', this);

if (this._observeChanges()) {
this._initializeDOMObserver();
}
},

/**
Expand Down Expand Up @@ -535,8 +599,8 @@
if (toHookMethod) {
if (when === HOOK_AFTER) {
this[method] = function () {
var ret = toHookMethod.apply(this, arguments);
return hookFn.call(this, ret);
toHookMethod.apply(this, arguments);
hookFn.apply(this, arguments);
};
} else if (when === HOOK_BEFORE) {
this[method] = function () {
Expand Down Expand Up @@ -883,6 +947,7 @@
this._endMoveRAF(); // Always cancel the debounce RAF

if (!this.enabled || !this.moved || (EVENT_TYPE[e.type] !== this._initiated)) {
this._initiated = false;
return;
}

Expand Down
12 changes: 6 additions & 6 deletions tasks/auratranspile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ module.exports = function(grunt) {
var DEPENDENCIES = 'build/dependencies.min.js',
SCROLLER = 'src/scroller.js',
SURFACEM = 'src/surface-manager.js',
SCROLLBARS = 'src/indicators-plugin.js',
PTR = 'src/pull-to-refresh.js',
PTL = 'src/pull-to-load-more.js',
IL = 'src/infinite-loading.js',
EP = 'src/endless-plugin.js',
SP = 'src/snap-plugin.js';
SCROLLBARS = 'src/plugins/indicators-plugin.js',
PTR = 'src/plugins/pull-to-refresh.js',
PTL = 'src/plugins/pull-to-load-more.js',
IL = 'src/plugins/infinite-loading.js',
EP = 'src/plugins/endless-plugin.js',
SP = 'src/plugins/snap-plugin.js';


grunt.registerTask('auratranspile', function () {
Expand Down
0