mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
I broke all the things
Making scroll working for ListView, inheriting from ScrollView like iOS.
This commit is contained in:
18
Gruntfile.js
18
Gruntfile.js
@ -18,7 +18,23 @@ module.exports = function(grunt) {
|
|||||||
'js/utils/**/*.js',
|
'js/utils/**/*.js',
|
||||||
|
|
||||||
// Views
|
// Views
|
||||||
'js/views/**/*.js',
|
'js/views/view.js',
|
||||||
|
|
||||||
|
'js/views/scrollView.js',
|
||||||
|
|
||||||
|
'js/views/actionSheetView.js',
|
||||||
|
'js/views/checkboxView.js',
|
||||||
|
'js/views/headerBarView.js',
|
||||||
|
'js/views/listView.js',
|
||||||
|
'js/views/ListViewScroll.js',
|
||||||
|
'js/views/loadingView.js',
|
||||||
|
'js/views/modalView.js',
|
||||||
|
'js/views/navBarView.js',
|
||||||
|
'js/views/popupView.js',
|
||||||
|
'js/views/sideMenuView.js',
|
||||||
|
'js/views/slideBox.js',
|
||||||
|
'js/views/tabBarView.js',
|
||||||
|
'js/views/toggleView.js',
|
||||||
|
|
||||||
// Controllers
|
// Controllers
|
||||||
'js/controllers/**/*.js'
|
'js/controllers/**/*.js'
|
||||||
|
|||||||
1208
dist/js/ionic.js
vendored
1208
dist/js/ionic.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,22 +1,59 @@
|
|||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
|
|
||||||
ionic.Utils = {
|
ionic.Utils = {
|
||||||
/**
|
// Borrowed from Backbone.js's extend
|
||||||
* extend method,
|
// Helper function to correctly set up the prototype chain, for subclasses.
|
||||||
* also used for cloning when dest is an empty object
|
// Similar to `goog.inherits`, but uses a hash of prototype properties and
|
||||||
* @param {Object} dest
|
// class properties to be extended.
|
||||||
* @param {Object} src
|
inherit: function(protoProps, staticProps) {
|
||||||
* @parm {Boolean} merge do a merge
|
var parent = this;
|
||||||
* @returns {Object} dest
|
var child;
|
||||||
*/
|
|
||||||
extend: function extend(dest, src, merge) {
|
// The constructor function for the new subclass is either defined by you
|
||||||
for (var key in src) {
|
// (the "constructor" property in your `extend` definition), or defaulted
|
||||||
if(dest[key] !== undefined && merge) {
|
// by us to simply call the parent's constructor.
|
||||||
continue;
|
if (protoProps && protoProps.hasOwnProperty('constructor')) {
|
||||||
|
child = protoProps.constructor;
|
||||||
|
} else {
|
||||||
|
child = function(){ return parent.apply(this, arguments); };
|
||||||
}
|
}
|
||||||
dest[key] = src[key];
|
|
||||||
}
|
// Add static properties to the constructor function, if supplied.
|
||||||
return dest;
|
ionic.extend(child, parent, staticProps);
|
||||||
|
|
||||||
|
// Set the prototype chain to inherit from `parent`, without calling
|
||||||
|
// `parent`'s constructor function.
|
||||||
|
var Surrogate = function(){ this.constructor = child; };
|
||||||
|
Surrogate.prototype = parent.prototype;
|
||||||
|
child.prototype = new Surrogate;
|
||||||
|
|
||||||
|
// Add prototype properties (instance properties) to the subclass,
|
||||||
|
// if supplied.
|
||||||
|
if (protoProps) ionic.extend(child.prototype, protoProps);
|
||||||
|
|
||||||
|
// Set a convenience property in case the parent's prototype is needed
|
||||||
|
// later.
|
||||||
|
child.__super__ = parent.prototype;
|
||||||
|
|
||||||
|
return child;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Extend adapted from Underscore.js
|
||||||
|
extend: function(obj) {
|
||||||
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
|
for(var i = 0; i < args.length; i++) {
|
||||||
|
var source = args[i];
|
||||||
|
if (source) {
|
||||||
|
for (var prop in source) {
|
||||||
|
obj[prop] = source[prop];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ionic.inherit = ionic.Utils.inherit;
|
||||||
|
ionic.extend = ionic.Utils.extend;
|
||||||
|
|
||||||
})(window.ionic);
|
})(window.ionic);
|
||||||
|
|||||||
@ -23,12 +23,13 @@
|
|||||||
toiletSeat: 'cubic-bezier(0.05, 0.60, 0.05, 0.60)'
|
toiletSeat: 'cubic-bezier(0.05, 0.60, 0.05, 0.60)'
|
||||||
};
|
};
|
||||||
|
|
||||||
ionic.views.ScrollView = function(opts) {
|
ionic.views.Scroll = ionic.views.View.inherit({
|
||||||
|
initialize: function(opts) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
// Extend the options with our defaults
|
// Extend the options with our defaults
|
||||||
opts = ionic.Utils.extend({
|
opts = ionic.Utils.extend({
|
||||||
decelerationRate: ionic.views.ScrollView.prototype.DECEL_RATE_NORMAL,
|
decelerationRate: ionic.views.Scroll.prototype.DECEL_RATE_NORMAL,
|
||||||
dragThreshold: 10,
|
dragThreshold: 10,
|
||||||
resistance: 2,
|
resistance: 2,
|
||||||
scrollEventName: 'momentumScrolled',
|
scrollEventName: 'momentumScrolled',
|
||||||
@ -68,12 +69,7 @@
|
|||||||
ionic.on('webkitTransitionEnd', function(e) {
|
ionic.on('webkitTransitionEnd', function(e) {
|
||||||
_this._onTransitionEnd(e);
|
_this._onTransitionEnd(e);
|
||||||
});
|
});
|
||||||
};
|
},
|
||||||
|
|
||||||
ionic.views.ScrollView.prototype = {
|
|
||||||
DECEL_RATE_NORMAL: 0.998,
|
|
||||||
DECEL_RATE_FAST: 0.99,
|
|
||||||
DECEL_RATE_SLOW: 0.996,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scroll to the given X and Y point, taking
|
* Scroll to the given X and Y point, taking
|
||||||
@ -541,6 +537,10 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}, {
|
||||||
|
DECEL_RATE_NORMAL: 0.998,
|
||||||
|
DECEL_RATE_FAST: 0.99,
|
||||||
|
DECEL_RATE_SLOW: 0.996,
|
||||||
|
});
|
||||||
|
|
||||||
})(ionic);
|
})(ionic);
|
||||||
|
|||||||
13
js/views/view.js
Normal file
13
js/views/view.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
(function(ionic) {
|
||||||
|
'use strict';
|
||||||
|
ionic.views.View = function() {
|
||||||
|
this.initialize.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
ionic.views.View.inherit = ionic.inherit;
|
||||||
|
|
||||||
|
ionic.extend(ionic.views.View.prototype, {
|
||||||
|
initialize: function() {}
|
||||||
|
});
|
||||||
|
|
||||||
|
})(window.ionic);
|
||||||
@ -43,7 +43,7 @@
|
|||||||
s.firstElementChild.appendChild(li);
|
s.firstElementChild.appendChild(li);
|
||||||
}
|
}
|
||||||
|
|
||||||
var scroll = new ionic.views.ScrollView({
|
var scroll = new ionic.views.Scroll({
|
||||||
el: s
|
el: s
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user