UNPKG

tram

Version:

Cross-browser CSS3 transitions in JavaScript

48 lines (39 loc) 1.28 kB
<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>tram.js example</title> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <link rel="stylesheet" href="../support/styles/example.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="../node_modules/jquery/dist/jquery.min.js"><\/script>')</script> <script src="../dist/tram.js"></script> </head> <body> <p> Testing how `display: none` affects set() and start(). </p> <div class="test hide"></div> <script> var test = $('.test'); function first() { tram(test).show().set({ opacity: 0, y: 50 }); tram(test).start({ opacity: 1, y: 0 }); } function second() { test[0].style.display = 'none'; // tram(test).hide(); // tram(test).set({ opacity: 0.5, y: 200 }); } var touch = 'ontouchstart' in window; var clicks = 0; $(document).on(touch ? 'touchstart' : 'mousedown', function () { switch (++clicks) { case 1: first(); break; case 2: second(); clicks = 0; break; } }); </script> </body> </html>