rotateEnd

触屏上用双指旋转某个 dom 元素结束时触发

定义

触屏上用双指旋转某个 dom 元素结束时触发

示例

<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <script src="//g.alicdn.com/kissy/k/1.4.7/seed.js" data-config="{combine:true}"></script>
</head>
<body>

<h1>open in ios safari test rotate event</h1>

<div id='t' tabindex='0'
     style='border:1px solid green;
     width:200px;height:200px;margin:10px'>
    rotate me
</div>

<script>

    KISSY.use('event', function (S, Event) {

        Event.on('#t', "rotateEnd", function (e) {
            S.log(e.type + ' : ' +
                    e.originalEvent.changedTouches[0].target.nodeName + ' : ' +
                    e.rotation + ' : ' + e.angle);
            //S.log(e.type + ' : ' + e.rotation);
        });

        Event.on('#t', "rotate rotateStart", function (e) {
            S.log(e.type + ' : ' +
                    e.originalEvent.touches.length + ' : ' +
                    e.rotation + ' : ' + e.angle);
            //S.log(e.type + ' : ' + e.rotation);
        });
        var t = document.getElementById('t');
        var o;
        Event.on('#t', 'rotateStart', function (e) {
            o = 0;
            if (t.style.WebkitTransform) {
                o = parseInt(t.style.WebkitTransform.replace(/rotate\(/, ''));
            }
        });
        Event.on('#t', 'rotate', function (e) {
            t.style.WebkitTransform = 'rotate(' + (o + parseInt(e.rotation))%360 + 'deg)';
        });


    });

</script>
</body>
</html>