| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- export function getCss(docEle) {
- const css = {};
- // transform
- var i;
- var keys = ['webkitTransform', '-webkit-transform', 'webkit-transform', 'transform'];
- for (i = 0; i < keys.length; i++) {
- if (docEle.style[keys[i]] !== undefined) {
- css.transform = keys[i];
- break;
- }
- }
- // transition
- keys = ['webkitTransition', 'transition'];
- for (i = 0; i < keys.length; i++) {
- if (docEle.style[keys[i]] !== undefined) {
- css.transition = keys[i];
- break;
- }
- }
- // The only prefix we care about is webkit for transitions.
- var isWebkit = css.transition.indexOf('webkit') > -1;
- // transition duration
- css.transitionDuration = (isWebkit ? '-webkit-' : '') + 'transition-duration';
- // transition timing function
- css.transitionTimingFn = (isWebkit ? '-webkit-' : '') + 'transition-timing-function';
- // transition delay
- css.transitionDelay = (isWebkit ? '-webkit-' : '') + 'transition-delay';
- // To be sure transitionend works everywhere, include *both* the webkit and non-webkit events
- css.transitionEnd = (isWebkit ? 'webkitTransitionEnd ' : '') + 'transitionend';
- // transform origin
- css.transformOrigin = (isWebkit ? '-webkit-' : '') + 'transform-origin';
- // animation delay
- css.animationDelay = (isWebkit ? 'webkitAnimationDelay' : 'animationDelay');
- return css;
- }
- export function pointerCoord(ev) {
- // get coordinates for either a mouse click
- // or a touch depending on the given event
- if (ev) {
- var changedTouches = ev.changedTouches;
- if (changedTouches && changedTouches.length > 0) {
- var touch = changedTouches[0];
- return { x: touch.clientX, y: touch.clientY };
- }
- var pageX = ev.pageX;
- if (pageX !== undefined) {
- return { x: pageX, y: ev.pageY };
- }
- }
- return { x: 0, y: 0 };
- }
- export function hasPointerMoved(threshold, startCoord, endCoord) {
- if (startCoord && endCoord) {
- const deltaX = (startCoord.x - endCoord.x);
- const deltaY = (startCoord.y - endCoord.y);
- const distance = deltaX * deltaX + deltaY * deltaY;
- return distance > (threshold * threshold);
- }
- return false;
- }
- export function isTextInput(ele) {
- return !!ele &&
- (ele.tagName === 'TEXTAREA' ||
- ele.contentEditable === 'true' ||
- (ele.tagName === 'INPUT' && !(NON_TEXT_INPUT_REGEX.test(ele.type))));
- }
- export const NON_TEXT_INPUT_REGEX = /^(radio|checkbox|range|file|submit|reset|color|image|button)$/i;
- const SKIP_INPUT_ATTR = ['value', 'checked', 'disabled', 'readonly', 'placeholder', 'type', 'class', 'style', 'id', 'autofocus', 'autocomplete', 'autocorrect'];
- export function copyInputAttributes(srcElement, destElement) {
- // copy attributes from one element to another
- // however, skip over a few of them as they're already
- // handled in the angular world
- const attrs = srcElement.attributes;
- for (var i = 0; i < attrs.length; i++) {
- var attr = attrs[i];
- if (SKIP_INPUT_ATTR.indexOf(attr.name) === -1) {
- destElement.setAttribute(attr.name, attr.value);
- }
- }
- }
- //# sourceMappingURL=dom.js.map
|