diff --git a/demo/sites/methods/touch.html b/demo/sites/methods/touch.html new file mode 100644 index 000000000..23cd68788 --- /dev/null +++ b/demo/sites/methods/touch.html @@ -0,0 +1,515 @@ + + +
+ + + + ++ Hold the button to remove the mask from the image +
++ Hold the button to remove the mask from the image with 5 seconds +
+Tap button to change a color
++ Change background color with 2 taps +
++ Swipe Left-Right to change a color +
++ Swipe Up-Down to change a color +
+
+ Importing components depends on how your application works. If you intend
+ to use the Tailwind Elements ES
format, you must first import
+ the component and then initialize it with the initTE
method.
+ If you are going to use the UMD
format, just import the
+ tw-elements
package.
+
+ Options can be passed via data attributes or JavaScript. For data
+ attributes, append the option name to data-te-
, as in
+ data-te-event="press"
.
+
+ Name + | ++ Type + | ++ Default + | +Description | +
---|---|---|---|
+ event
+ |
+ + String + | +
+ 'swipe'
+ |
+
+ Event type. Can be 'pan' , 'pinch' ,
+ 'press' , 'rotate' ,
+ 'swipe' , 'tap' .
+ |
+
+ Name + | ++ Type + | ++ Default + | +Description | +
---|---|---|---|
+ direction
+ |
+ + String + | +
+ 'all'
+ |
+
+ Set direction to pan. Available options: all ,
+ right , left , up ,
+ down .
+ |
+
+ pointers
+ |
+ + Number + | +
+ 1
+ |
+ + Set default value of number for pointers. + | +
+ threshold
+ |
+ + Number + | +
+ 20
+ |
+ + Set distance bettwen when event fires. + | +
+ Name + | ++ Type + | ++ Default + | +Description | +
---|---|---|---|
+ pointers
+ |
+ + Number + | +
+ 2
+ |
+
+ Option for tap event, set duration to how long
+ it takes to take a tap.
+ |
+
+ threshold
+ |
+ + Number + | +
+ 10
+ |
+ + Set distance bettwen when event fires. + | +
+ Name + | ++ Type + | ++ Default + | +Description | +
---|---|---|---|
+ pointers
+ |
+ + Number + | +
+ 1
+ |
+ + Set default value of number for pointers. + | +
+ time
+ |
+ + Number + | +
+ 250
+ |
+ + Set time delays to take tap. + | +
+ Name + | ++ Type + | ++ Default + | +Description | +
---|---|---|---|
+ angle
+ |
+ + Number + | +
+ 0
+ |
+ + Set started angle to rotate. + | +
+ pointers
+ |
+ + Number + | +
+ 2
+ |
+ + Set default value of number for pointers. + | +
+ Name + | ++ Type + | ++ Default + | +Description | +
---|---|---|---|
+ direction
+ |
+ + String + | +
+ 'all'
+ |
+
+ Set direction to pan. Available options: all ,
+ right , left , up ,
+ down .
+ |
+
+ treshold
+ |
+ + Number + | +
+ 10
+ |
+ + Set distance bettwen when event fires. + | +
+ Name + | ++ Type + | ++ Default + | +Description | +
---|---|---|---|
+ interval
+ |
+ + Number + | +
+ 500
+ |
+ + Set interval to tap. + | +
+ pointers
+ |
+ + Number + | +
+ 1
+ |
+ + Set default value of number for pointers. + | +
+ taps
+ |
+ + Number + | +
+ 1
+ |
+ + Set default value of number for taps. + | +
+ time
+ |
+ + Number + | +
+ 250
+ |
+ + Set delays time to tap event. + | +
+ Method + | ++ Description + | +Example | +
---|---|---|
+ dispose
+ |
+ + Manually disposes an instance. + | +
+ touch.dispose();
+ |
+
+ getInstance
+ |
+ + Static method which allows you to get the touch instance + associated to a DOM element. + | +
+ Touch.getInstance(element)
+ |
+
+ getOrCreateInstance
+ |
+ + Static method which returns the touch instance associated to + a DOM element or create a new one in case it wasn't + initialized. + | +
+ Touch.getOrCreateInstance(element)
+ |
+
+ Event type + | +Description | +
---|---|
+ pan
+ |
+ + This event fires pan touch funcionality. + | +
+ pinch
+ |
+ + This event fires pinch touch funcionality. + | +
+ press
+ |
+ + This event fires press touch funcionality. + | +
+ rotate
+ |
+ + This event fires rotate touch funcionality. + | +
+ swipe
+ |
+ + This event fires swipe touch funcionality. + | +
+ tap
+ |
+ + This event fires tap touch funcionality. + | +
+ Press calls the chosen method when the touch event on the element lasts + longer than 250 milliseconds. +
+ + + {{< twsnippet/demo id="example1">}} ++ Hold the button to remove the mask from the image +
++ Hey there 👋 we want to make Tailwind Elements a + community-driven project. It's open source and free, and + we would like it to stay that way. If you enjoy it, + help the project grow by sharing it with your peers. + Every share counts, thank you! +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Touch event press with custom duration.
+ + + {{< twsnippet/demo id="example2">}} ++ Hold the button to remove the mask from the image with 5 seconds +
++ The callback on tap event is called with an object containing origin field - + the x and y cooridinates of the user's touch. +
+ + + {{< twsnippet/demo id="example3">}} +Tap button to change a color
+Set default taps to touch event.
+ + + {{< twsnippet/demo id="example4">}} ++ Change background color with 2 taps +
++ The pan event is useful for dragging elements - every time the user moves a + finger on the element to which the directive is attached to, the given + method is being called with an argument consisting of two keys: x and y (the + values corresponds to the horizontal and vertical translation). +
+ + + {{< twsnippet/demo id="example5">}} +Pan with only left direction.
+ + + {{< twsnippet/demo id="example6">}} +Pan with only right direction.
+ + + {{< twsnippet/demo id="example7">}} +Pan with only up/down direction.
+ + + {{< twsnippet/demo id="example8">}} ++ The pinch event calls the given method with an object containing two keys - + ratio and origin. The first one it the ratio of the distance between user's + fingers on touchend to the same distance on touchstart - it's particularly + useful for scaling images. The second one, similarly as in doubleTap event, + is a pair of coordinates indicating the middle point between the user's + fingers. +
+ + + {{< twsnippet/demo id="example9">}} ++ The swipe event comes with several modifiers (left, right, up, down) - each + of them will ensure that event will fire only on swipe in that particular + direction. If the directive is used without any modifier, the callback + method will be called each time the swiping occurs, and the string + indicating the direction will be passed as an argument. +
+ +This example shows example with left and right:
+ + + {{< twsnippet/demo id="example10">}} ++ Swipe Left-Right to change a color +
+This example shows example with up and down:
+ + + {{< twsnippet/demo id="example11">}} +Swipe Up-Down to change a color
+This example shows example with rotate:
+ + + {{< twsnippet/demo id="example12">}} +