|
发表于 2017-1-6 16:23:17
|
显示全部楼层
- var dx, dy; //偏移
- var initialScale = 1;
- var currentScale; // 缩放
- Model.prototype.pinch = function(event) {
- var id = this.getIDByXID('pinch');
- var target = document.getElementById(id);
- // target.style.webkitTransition = 'all ease 0.05s';
- touch.on('#' + id, 'touchstart', function(ev) {
- ev.preventDefault();
- });
- touch.on('#' + id, 'drag', function(ev) {
- dx = dx || 0;
- dy = dy || 0;
- var offx = dx + ev.x + "px";
- var offy = dy + ev.y + "px";
- this.style.webkitTransform = "translate3d(" + offx + "," + offy + ",0)";
- });
- touch.on('#' + id, 'dragend', function(ev) {
- dx += ev.x;
- dy += ev.y;
- });
- touch.on('#' + id, 'pinch', function(ev) {
- ev.hasStopedPropagation = true;
- currentScale = ev.scale - 1;
- currentScale = initialScale + currentScale;
- currentScale = currentScale < 1 ? 1 : currentScale;
- this.style.webkitTransform = 'scale(' + currentScale + ')';
- });
- touch.on('#' + id, 'pinchend', function(ev) {
- initialScale = currentScale;
- });
- };
复制代码
麻烦您看一下这样有什么问题吗,这样子改完以后缩放和偏移都能记录,但是还是合不到一起去 |
|