diff --git a/css/style.css b/css/style.css
index 7471852..79402d8 100644
--- a/css/style.css
+++ b/css/style.css
@@ -1 +1,144 @@
-.drag{-webkit-transition:-webkit-transform 0s linear,opacity 0s linear!important}html,body{margin:0;padding:0;height:100%;font-family:Helvetica,Arial,sans-serif;font-size:19px;font-weight:bold;color:#fff}#fork-ribbon{display:none}#wrapper{position:absolute;width:100%;height:100%;top:0;left:0;background:#000;overflow:hidden}#list-view{z-index:1}.list{-webkit-transform:translate3d(0,0,0);-webkit-transition:opacity .3s cubic-bezier(0.64,0.16,0.39,0.83);position:absolute;width:100%;top:0;left:0;z-index:0}.list.fade{opacity:0}.item{text-shadow:0 1px 1px rgba(0,0,0,0.25);-webkit-transition:-webkit-transform .3s cubic-bezier(0.64,0.16,0.39,0.83),background-color .3s cubic-bezier(0.64,0.16,0.39,0.83),opacity .3s cubic-bezier(0.64,0.16,0.39,0.83);position:absolute;width:100%;top:0;left:0;height:64px}.item .inner{cursor:pointer;position:relative;-webkit-transform:translate3d(0,0,0);height:64px;line-height:64px;box-sizing:border-box;padding-left:12px;border-top:1px solid rgba(255,255,255,0.07);border-bottom:1px solid rgba(0,0,0,0.1)}.list-item{background-color:#0086f3}.list-item .count{position:absolute;width:64px;height:63px;right:0;top:-1px;background-color:rgba(255,255,255,0.15);text-align:center}.list-item.empty{color:rgba(255,255,255,0.5);text-shadow:0 1px 1px rgba(0,0,0,0.13)}body.desktop{background:url(../img/bg.png) center center no-repeat}body.desktop *{-webkit-user-select:none}body.desktop img{-webkit-user-drag:none}body.desktop #wrapper{width:320px;height:548px;top:50%;left:50%;margin-top:-259px;margin-left:-160px}body.desktop #fork-ribbon{display:inline}#log{position:absolute;bottom:5px;width:100%;left:0;text-align:center;font-size:14px}
\ No newline at end of file
+.drag {
+ -webkit-transition: -webkit-transform 0s linear, opacity 0s linear !important;
+}
+html,
+body {
+ margin: 0;
+ padding: 0;
+ height: 100%;
+ font-family: Helvetica, Arial, sans-serif;
+ font-size: 19px;
+ font-weight: bold;
+ color: #fff;
+}
+#fork-ribbon {
+ display: none;
+}
+#wrapper {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ top: 0;
+ left: 0;
+ background: #000;
+ overflow: hidden;
+}
+#list-view {
+ z-index: 1;
+}
+.list {
+ -webkit-transform: translate3d(0, 0, 0);
+ -webkit-transition: opacity 0.3s cubic-bezier(0.64, 0.16, 0.39, 0.83);
+ position: absolute;
+ width: 100%;
+ top: 0;
+ left: 0;
+ z-index: 0;
+}
+.list.fade {
+ opacity: 0;
+}
+.item {
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
+ -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.64, 0.16, 0.39, 0.83), opacity 0.3s cubic-bezier(0.64, 0.16, 0.39, 0.83);
+ position: absolute;
+ z-index: 0;
+ width: 100%;
+ top: 0;
+ left: 0;
+ height: 64px;
+}
+.item .slider {
+ -webkit-transition: background-color 0.15s cubic-bezier(0.64, 0.16, 0.39, 0.83), color 0.15s cubic-bezier(0.64, 0.16, 0.39, 0.83);
+ cursor: pointer;
+ position: relative;
+ z-index: 1;
+ height: 64px;
+}
+.item .slider .inner {
+ -webkit-transform: translate3d(0, 0, 0);
+ box-sizing: border-box;
+ padding-left: 12px;
+ border-top: 1px solid rgba(255, 255, 255, 0.07);
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
+ height: 64px;
+ line-height: 64px;
+}
+.item .check,
+.item .cross {
+ width: 64px;
+ height: 64px;
+ position: absolute;
+ z-index: 0;
+ top: 0;
+ opacity: 0;
+}
+.item .check {
+ left: 0;
+}
+.item .cross {
+ right: 0;
+}
+.list-item .count {
+ position: absolute;
+ width: 64px;
+ height: 63px;
+ right: 0;
+ top: -1px;
+ background-color: rgba(255, 255, 255, 0.15);
+ text-align: center;
+}
+.list-item.empty {
+ color: rgba(255, 255, 255, 0.5);
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.13);
+}
+.todo-item .line {
+ position: absolute;
+ height: 2px;
+ left: 10px;
+ top: 31px;
+ width: 0;
+ background-color: #fff;
+ -webkit-transition: width 0s linear, background-color 0.15s cubic-bezier(0.64, 0.16, 0.39, 0.83);
+}
+.todo-item.done {
+ z-index: 1;
+ color: #666;
+}
+.todo-item.done .slider {
+ background-color: #000 !important;
+}
+.todo-item.done .line {
+ background-color: #666;
+}
+.todo-item.green .slider {
+ background-color: #0A3 !important;
+}
+body.desktop {
+ background: url(../img/bg.png) center center no-repeat;
+}
+body.desktop * {
+ -webkit-user-select: none;
+}
+body.desktop img {
+ -webkit-user-drag: none;
+}
+body.desktop #wrapper {
+ width: 320px;
+ height: 548px;
+ top: 50%;
+ left: 50%;
+ margin-top: -259px;
+ margin-left: -160px;
+}
+body.desktop #fork-ribbon {
+ display: inline;
+}
+#log {
+ position: absolute;
+ bottom: 5px;
+ width: 100%;
+ left: 0;
+ text-align: center;
+ font-size: 14px;
+}
diff --git a/css/style.less b/css/style.less
index 50a574a..04bc9d0 100644
--- a/css/style.less
+++ b/css/style.less
@@ -50,28 +50,52 @@ html, body {
.item {
text-shadow: 0 1px 1px rgba(0,0,0,.25);
-webkit-transition: -webkit-transform .3s @ease,
- background-color .3s @ease,
opacity .3s @ease;
position: absolute;
+ z-index: 0;
width: 100%;
top: 0;
left: 0;
height: @itemHeight;
- .inner {
+
+ .slider {
+ -webkit-transition: background-color .15s @ease,
+ color .15s @ease;
cursor: pointer;
position: relative;
- -webkit-transform: translate3d(0,0,0);
+ z-index: 1;
height: @itemHeight;
- line-height: @itemHeight;
- box-sizing: border-box;
- padding-left: 12px;
- border-top: 1px solid rgba(255,255,255,.07);
- border-bottom: 1px solid rgba(0,0,0,.1);
+
+ .inner {
+ -webkit-transform: translate3d(0,0,0);
+ box-sizing: border-box;
+ padding-left: 12px;
+ border-top: 1px solid rgba(255,255,255,.07);
+ border-bottom: 1px solid rgba(0,0,0,.1);
+ height: @itemHeight;
+ line-height: @itemHeight;
+ }
+ }
+
+ .check, .cross {
+ width: 64px;
+ height: 64px;
+ position: absolute;
+ z-index: 0;
+ top: 0;
+ opacity: 0;
+ }
+
+ .check {
+ left: 0;
+ }
+
+ .cross {
+ right: 0;
}
}
.list-item {
- background-color: #0086F3;
.count {
position: absolute;
@@ -89,6 +113,37 @@ html, body {
}
}
+.todo-item {
+
+ .line {
+ position: absolute;
+ height: 2px;
+ left: 10px;
+ top: 31px;
+ width: 0;
+ background-color: #fff;
+ -webkit-transition: width 0s linear,
+ background-color .15s @ease;
+ }
+
+ &.done {
+ z-index: 1;
+ color: #666;
+ .slider {
+ background-color: #000 !important;
+ }
+ .line {
+ background-color: #666;
+ }
+ }
+
+ &.green {
+ .slider {
+ background-color: #0A3 !important;
+ }
+ }
+}
+
// Desktop
body.desktop {
diff --git a/img/check.png b/img/check.png
new file mode 100755
index 0000000..631ce58
Binary files /dev/null and b/img/check.png differ
diff --git a/img/cross.png b/img/cross.png
new file mode 100755
index 0000000..a8c96a2
Binary files /dev/null and b/img/cross.png differ
diff --git a/js/item.js b/js/item.js
index 533925a..00713ed 100644
--- a/js/item.js
+++ b/js/item.js
@@ -13,36 +13,118 @@ C.Item = (function () {
this.render();
+ this.style = this.el[0].style;
+ this.slider = this.el.find('.slider');
+ this.sliderStyle = this.slider[0].style;
+
+ this.check = $('');
+ this.cross = $('
');
+ this.el
+ .append(this.check)
+ .append(this.cross);
+
+ this.checkStyle = this.check[0].style;
+ this.crossStyle = this.cross[0].style;
+
+ this.checkX = 0;
+ this.crossX = 0;
+ this.checkO = 0;
+ this.crossO = 0;
+
+ },
+
+ updatePosition: function () {
+
+ this.y = this.data.order * 64;
+ this.style.webkitTransform = 'translate3d(0,' + this.y + 'px, 0)';
+
},
onDragStart: function () {
- this.el.addClass('drag');
+ this.slider.addClass('drag');
+ this.checkX = this.crossX = 0;
+ this.checkStyle.webkitTransform = this.crossStyle.webkitTransform = 'translate3d(0,0,0)';
},
onDragMove: function (dx) {
- if (this.noDragRight && this.x + dx > 0) return;
- if (this.noDragLeft && this.x + dx < 0) return;
+ var tx = this.x + dx;
+
+ if (this.noDragRight && tx > 0) return;
+ if (this.noDragLeft && tx < 0) return;
+
+ if (tx > 0) { // dragging to right
+
+ if (this.noDragRight) return;
+ if (tx <= rightBound) {
+
+ this.checkO = tx / rightBound;
+ this.checkStyle.opacity = this.checkO;
+
+ if (this.checkX != 0) {
+ this.checkX = 0;
+ this.checkStyle.webkitTransform = 'translate3d(0, 0, 0)';
+ }
+
+ } else { // over bound
+
+ dx /= 3;
+ this.checkX = Math.max(0, (this.x + dx) - rightBound);
+ this.checkStyle.webkitTransform = 'translate3d(' + this.checkX + 'px, 0, 0)';
+
+ if (this.checkO != 1) {
+ this.checkO = 1;
+ this.checkStyle.opacity = 1;
+ }
+
+ }
+
+ } else if (tx < 0) { // dragging to left
+
+ if (this.noDragLeft) return;
+ if (tx >= leftBound) {
+
+ this.crossO = tx / leftBound;
+ this.crossStyle.opacity = this.crossO;
+
+ if (this.crossX != 0) {
+ this.crossX = 0;
+ this.crossStyle.webkitTransform = 'translate3d(0, 0, 0)';
+ }
+
+ } else { // over bound
+
+ dx /= 3;
+ this.crossX = Math.min(0, (this.x + dx) - leftBound);
+ this.crossStyle.webkitTransform = 'translate3d(' + this.crossX + 'px, 0, 0)';
+
+ if (this.crossO != 1) {
+ this.crossO = 1;
+ this.crossStyle.opacity = 1;
+ }
+
+ }
- if (this.x + dx < leftBound || this.x + dx > rightBound) {
- dx /= 3;
}
this.x += dx;
- this.style.webkitTransform = 'translate3d(' + this.x + 'px,' + this.y + 'px, 0)';
+ this.sliderStyle.webkitTransform = 'translate3d(' + this.x + 'px, 0, 0)';
},
onDragEnd: function () {
- var item = this;
+ var item = this,
+ complete;
if (item.x < leftBound) {
- this.del();
+ complete = this.del;
} else if (item.x > rightBound) {
- this.done();
+ complete = this.done;
+ } else {
+ complete = this.cancel;
}
loop();
@@ -50,19 +132,24 @@ C.Item = (function () {
function loop () {
item.x *= .6;
- item.style.webkitTransform = 'translate3d(' + item.x + 'px,' + item.y + 'px, 0)';
+ item.sliderStyle.webkitTransform = 'translate3d(' + item.x + 'px, 0, 0)';
if (Math.abs(item.x) > 0.1) {
setTimeout(loop, 16);
} else {
item.x = 0;
- item.style.webkitTransform = 'translate3d(' + item.x + 'px,' + item.y + 'px, 0)';
- item.el.removeClass('drag');
+ item.sliderStyle.webkitTransform = 'translate3d(' + item.x + 'px, 0, 0)';
+ item.slider.removeClass('drag');
+
+ complete.call(item);
+
}
}
- }
+ },
+
+
};
diff --git a/js/listItem.js b/js/listItem.js
index 1cf79b6..9a44832 100644
--- a/js/listItem.js
+++ b/js/listItem.js
@@ -35,20 +35,18 @@
this.el = $('