mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
Swipe left for list items in the works
This commit is contained in:
1826
dist/ionic-ios7.css
vendored
1826
dist/ionic-ios7.css
vendored
File diff suppressed because it is too large
Load Diff
3
dist/ionic.css
vendored
3
dist/ionic.css
vendored
@ -1124,6 +1124,9 @@ a.list-item {
|
|||||||
text-decoration: none; }
|
text-decoration: none; }
|
||||||
a.list-item:hover, a.list-item:focus {
|
a.list-item:hover, a.list-item:focus {
|
||||||
text-decoration: none; }
|
text-decoration: none; }
|
||||||
|
a.list-item.slide-left {
|
||||||
|
margin-left: -100px;
|
||||||
|
-webkit-transition: margin-left 0.2s ease-in-out; }
|
||||||
|
|
||||||
.list-divider {
|
.list-divider {
|
||||||
padding: 5px 15px;
|
padding: 5px 15px;
|
||||||
|
|||||||
47
dist/ionic.js
vendored
47
dist/ionic.js
vendored
@ -177,7 +177,7 @@ window.ionic = {
|
|||||||
* Simple gesture controllers with some common gestures that emit
|
* Simple gesture controllers with some common gestures that emit
|
||||||
* gesture events.
|
* gesture events.
|
||||||
*
|
*
|
||||||
* Ported from github.com/EightMedia/hammer.js - thanks!
|
* Ported from github.com/EightMedia/ionic.Gestures.js - thanks!
|
||||||
*/
|
*/
|
||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
|
|
||||||
@ -265,19 +265,11 @@ window.ionic = {
|
|||||||
ionic.Gestures.event.determineEventTypes();
|
ionic.Gestures.event.determineEventTypes();
|
||||||
|
|
||||||
// Register all gestures inside ionic.Gestures.gestures
|
// Register all gestures inside ionic.Gestures.gestures
|
||||||
if(this === this.window) {
|
|
||||||
// this is a window, then only allow the Tap gesture to be added
|
|
||||||
ionic.Gestures.detection.register(ionic.Gestures.gestures.Tap);
|
|
||||||
ionic.Gestures.detection.register(ionic.Gestures.gestures.Drag);
|
|
||||||
ionic.Gestures.detection.register(ionic.Gestures.gestures.Release);
|
|
||||||
} else {
|
|
||||||
// everything else but the window
|
|
||||||
for(var name in ionic.Gestures.gestures) {
|
for(var name in ionic.Gestures.gestures) {
|
||||||
if(ionic.Gestures.gestures.hasOwnProperty(name)) {
|
if(ionic.Gestures.gestures.hasOwnProperty(name)) {
|
||||||
ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
|
ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Add touch events on the document
|
// Add touch events on the document
|
||||||
ionic.Gestures.event.onTouch(ionic.Gestures.DOCUMENT, ionic.Gestures.EVENT_MOVE, ionic.Gestures.detection.detect);
|
ionic.Gestures.event.onTouch(ionic.Gestures.DOCUMENT, ionic.Gestures.EVENT_MOVE, ionic.Gestures.detection.detect);
|
||||||
@ -1784,6 +1776,43 @@ window.ionic = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
})(ionic);
|
||||||
|
;
|
||||||
|
(function(ionic) {
|
||||||
|
|
||||||
|
ionic.views.List = function(opts) {
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
|
this.el = opts.el;
|
||||||
|
|
||||||
|
window.ionic.onGesture('swipeleft', function(e) {
|
||||||
|
_this._handleSwipeLeft(e);
|
||||||
|
}, this.el);
|
||||||
|
|
||||||
|
window.ionic.onGesture('swiperight', function(e) {
|
||||||
|
_this._handleSwipeRight(e);
|
||||||
|
}, this.el);
|
||||||
|
};
|
||||||
|
|
||||||
|
ionic.views.List.prototype = {
|
||||||
|
_handleSwipeLeft: function(e) {
|
||||||
|
var item = e.target;
|
||||||
|
if(!item.classList.contains('list-item')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.classList.add('slide-left');
|
||||||
|
},
|
||||||
|
_handleSwipeRight: function(e) {
|
||||||
|
var item = e.target;
|
||||||
|
if(!item.classList.contains('list-item')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.classList.remove('slide-left');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
})(ionic);
|
})(ionic);
|
||||||
;
|
;
|
||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Simple gesture controllers with some common gestures that emit
|
* Simple gesture controllers with some common gestures that emit
|
||||||
* gesture events.
|
* gesture events.
|
||||||
*
|
*
|
||||||
* Ported from github.com/EightMedia/hammer.js - thanks!
|
* Ported from github.com/EightMedia/ionic.Gestures.js - thanks!
|
||||||
*/
|
*/
|
||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
|
|
||||||
@ -90,19 +90,11 @@
|
|||||||
ionic.Gestures.event.determineEventTypes();
|
ionic.Gestures.event.determineEventTypes();
|
||||||
|
|
||||||
// Register all gestures inside ionic.Gestures.gestures
|
// Register all gestures inside ionic.Gestures.gestures
|
||||||
if(this === this.window) {
|
|
||||||
// this is a window, then only allow the Tap gesture to be added
|
|
||||||
ionic.Gestures.detection.register(ionic.Gestures.gestures.Tap);
|
|
||||||
ionic.Gestures.detection.register(ionic.Gestures.gestures.Drag);
|
|
||||||
ionic.Gestures.detection.register(ionic.Gestures.gestures.Release);
|
|
||||||
} else {
|
|
||||||
// everything else but the window
|
|
||||||
for(var name in ionic.Gestures.gestures) {
|
for(var name in ionic.Gestures.gestures) {
|
||||||
if(ionic.Gestures.gestures.hasOwnProperty(name)) {
|
if(ionic.Gestures.gestures.hasOwnProperty(name)) {
|
||||||
ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
|
ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Add touch events on the document
|
// Add touch events on the document
|
||||||
ionic.Gestures.event.onTouch(ionic.Gestures.DOCUMENT, ionic.Gestures.EVENT_MOVE, ionic.Gestures.detection.detect);
|
ionic.Gestures.event.onTouch(ionic.Gestures.DOCUMENT, ionic.Gestures.EVENT_MOVE, ionic.Gestures.detection.detect);
|
||||||
|
|||||||
36
js/views/listView.js
Normal file
36
js/views/listView.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
(function(ionic) {
|
||||||
|
|
||||||
|
ionic.views.List = function(opts) {
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
|
this.el = opts.el;
|
||||||
|
|
||||||
|
window.ionic.onGesture('swipeleft', function(e) {
|
||||||
|
_this._handleSwipeLeft(e);
|
||||||
|
}, this.el);
|
||||||
|
|
||||||
|
window.ionic.onGesture('swiperight', function(e) {
|
||||||
|
_this._handleSwipeRight(e);
|
||||||
|
}, this.el);
|
||||||
|
};
|
||||||
|
|
||||||
|
ionic.views.List.prototype = {
|
||||||
|
_handleSwipeLeft: function(e) {
|
||||||
|
var item = e.target;
|
||||||
|
if(!item.classList.contains('list-item')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.classList.add('slide-left');
|
||||||
|
},
|
||||||
|
_handleSwipeRight: function(e) {
|
||||||
|
var item = e.target;
|
||||||
|
if(!item.classList.contains('list-item')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.classList.remove('slide-left');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})(ionic);
|
||||||
@ -87,6 +87,11 @@ a.list-item {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
//background-color: $list-group-hover-bg;
|
//background-color: $list-group-hover-bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.slide-left {
|
||||||
|
margin-left: -100px;
|
||||||
|
-webkit-transition: margin-left 0.2s ease-in-out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-divider {
|
.list-divider {
|
||||||
|
|||||||
@ -16,8 +16,9 @@
|
|||||||
<h1 class="title">Customers</h1>
|
<h1 class="title">Customers</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main class="has-header">
|
<main class="content-wrapper">
|
||||||
<ul class="list">
|
<div class="content has-header">
|
||||||
|
<ul id="list" class="list">
|
||||||
<a href="#" class="list-item">
|
<a href="#" class="list-item">
|
||||||
Sasafras
|
Sasafras
|
||||||
<i class="icon-arrow-right"></i>
|
<i class="icon-arrow-right"></i>
|
||||||
@ -73,12 +74,16 @@
|
|||||||
</a>
|
</a>
|
||||||
</ul>
|
</ul>
|
||||||
<p><a class="button button-secondary" href="index.html">Homepage</a></p>
|
<p><a class="button button-secondary" href="index.html">Homepage</a></p>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script src="../dist/ionic.js"></script>
|
<script src="../dist/ionic.js"></script>
|
||||||
<script src="../dist/ionic-simple.js"></script>
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var l = document.getElementById('list');
|
||||||
|
var list = new ionic.views.List({el: l});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user