AlloyFinger、css3transform

AlloyFinger

npm install alloyfinger

demo:

? ? ? ? var pinchImg = document.getElementById("pinchImg");

? ? ? ? Transform(pinchImg);

? ? ? ? var initScale = 1;

? ? ? ? new AlloyFinger(pinchImg, {

? ? ? ? ? ? multipointStart: function () {

? ? ? ? ? ? ? ? initScale = pinchImg.scaleX;

? ? ? ? ? ? },

? ? ? ? ? ? pinch: function (evt) {

? ? ? ? ? ? ? ? pinchImg.scaleX = pinchImg.scaleY = initScale * evt.zoom;

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? var rotateImg = document.getElementById("rotateImg");

? ? ? ? Transform(rotateImg);

? ? ? ? new AlloyFinger(rotateImg, {

? ? ? ? ? ? rotate:function(evt){

? ? ? ? ? ? ? ? rotateImg.rotateZ += evt.angle;

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? var pinchRotateImg = document.getElementById("pinchRotateImg");

? ? ? ? Transform(pinchRotateImg);

? ? ? ? new AlloyFinger(pinchRotateImg, {

? ? ? ? ? ? rotate:function(evt){

? ? ? ? ? ? ? ? pinchRotateImg.rotateZ += evt.angle;

? ? ? ? ? ? },

? ? ? ? ? ? multipointStart: function () {

? ? ? ? ? ? ? ? initScale = pinchRotateImg.scaleX;

? ? ? ? ? ? },

? ? ? ? ? ? pinch: function (evt) {

? ? ? ? ? ? ? ? pinchRotateImg.scaleX = pinchRotateImg.scaleY = initScale * evt.zoom;

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? var pressMoveImg = document.getElementById("pressMoveImg");

? ? ? ? Transform(pressMoveImg);

? ? ? ? new AlloyFinger(pressMoveImg, {

? ? ? ? ? ? pressMove:function(evt){

? ? ? ? ? ? ? ? pressMoveImg.translateX += evt.deltaX;

? ? ? ? ? ? ? ? pressMoveImg.translateY += evt.deltaY;

? ? ? ? ? ? ? ? evt.preventDefault();

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? function ease(x) {

? ? ? ? ? ? return Math.sqrt(1 - Math.pow(x - 1, 2));

? ? ? ? }

? ? ? ? var doubleTapImg = document.getElementById("doubleTapImg");

? ? ? ? Transform(doubleTapImg);

? ? ? ? new AlloyFinger(doubleTapImg, {

? ? ? ? ? ? doubleTap:function(){

? ? ? ? ? ? ? ? if(doubleTapImg.scaleX===1){

? ? ? ? ? ? ? ? ? ? new To(doubleTapImg, "scaleX", 2, 500, ease);

? ? ? ? ? ? ? ? ? ? new To(doubleTapImg, "scaleY", 2, 500, ease);

? ? ? ? ? ? ? ? }else if(doubleTapImg.scaleX===2){

? ? ? ? ? ? ? ? ? ? new To(doubleTapImg, "scaleX", 1, 500, ease);

? ? ? ? ? ? ? ? ? ? new To(doubleTapImg, "scaleY", 1, 500, ease);

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? var swipeScroll = document.getElementById("swipeScroll"),

? ? ? ? ? ? currentIndex=0;

? ? ? ? Transform(swipeScroll);

? ? ? ? function activeNav(index){

? ? ? ? ? ? var items = document.querySelectorAll(".nuclear-nav a"),

? ? ? ? ? ? ? ? ? ? i = 0,

? ? ? ? ? ? ? ? ? ? len = items.length;

? ? ? ? ? ? for (; i < len; i++) {

? ? ? ? ? ? ? ? if (i === index) {

? ? ? ? ? ? ? ? ? ? items[i].classList.add("active");

? ? ? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? ? ? items[i].classList.remove("active");

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? new AlloyFinger(swipeScroll, {

? ? ? ? ? ? touchMove:function(evt) {

? ? ? ? ? ? ? ? if (Math.abs(evt.deltaX) >= Math.abs(evt.deltaY)) {

? ? ? ? ? ? ? ? ? ? evt.preventDefault();

? ? ? ? ? ? ? ? }

? ? ? ? ? ? },

? ? ? ? ? ? swipe:function(evt){

? ? ? ? ? ? ? ? if(evt.direction==="Left"){

? ? ? ? ? ? ? ? ? ? if(currentIndex<2) {

? ? ? ? ? ? ? ? ? ? ? ? currentIndex++;

? ? ? ? ? ? ? ? ? ? ? ? new To(swipeScroll, "translateX", -160 * currentIndex, 500, ease, function () {

? ? ? ? ? ? ? ? ? ? ? ? ? ? activeNav(currentIndex);

? ? ? ? ? ? ? ? ? ? ? ? });

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }else if(evt.direction==="Right"){

? ? ? ? ? ? ? ? ? ? if(currentIndex>0) {

? ? ? ? ? ? ? ? ? ? ? ? currentIndex--;

? ? ? ? ? ? ? ? ? ? ? ? new To(swipeScroll, "translateX", -160 * currentIndex, 500, ease, function () {

? ? ? ? ? ? ? ? ? ? ? ? ? ? activeNav(currentIndex);

? ? ? ? ? ? ? ? ? ? ? ? });

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? var longTapBox = document.getElementById("longTapBox");

? ? ? ? Transform(longTapBox);

? ? ? ? var overlay=document.getElementById("overlay");

? ? ? ? new AlloyFinger(longTapBox, {

? ? ? ? ? ? longTap:function(evt){

? ? ? ? ? ? ? ? evt.preventDefault();

? ? ? ? ? ? ? ? toggleDom(overlay);

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? var tapBox = document.getElementById("tapBox");

? ? ? ? Transform(tapBox);

? ? ? ? var overlay2=document.getElementById("overlay2");

? ? ? ? new AlloyFinger(tapBox, {

? ? ? ? ? ? tap:function(){

? ? ? ? ? ? ? ? toggleDom(overlay2);

? ? ? ? ? ? },

? ? ? ? ? ? singleTap:function(){

? ? ? ? ? ? ? ? console.log("singleTap")

? ? ? ? ? ? },

? ? ? ? ? ? doubleTap:function(){

? ? ? ? ? ? ? ? console.log("doubleTap")

? ? ? ? ? ? },

? ? ? ? ? ? pointStart:function(){

? ? ? ? ? ? ? ? console.log("pointStart")

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? function toggleDom(dom){

? ? ? ? ? ? var displayValue=window.getComputedStyle(dom,null)["display"];

? ? ? ? ? ? if(displayValue==="none"){

? ? ? ? ? ? ? ? dom.style.display="block";

? ? ? ? ? ? }else{

? ? ? ? ? ? ? ? dom.style.display="none";

? ? ? ? ? ? }

? ? ? ? }


css3transform

npm install css3transform


引用頁(yè):

import AlloyFinger from 'alloyfinger'

import AlloyFingerPlugin from 'alloyfinger/vue/alloy_finger_vue'

import Transform from 'css3transform'

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容