Move
How do I make an move?
What is a move? How do you make a move? This script and codes were developed by James Crockford on 19 November 2022, Saturday.
Move - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Move</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="origin"></div>
<div class="destination"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Move - Script Codes CSS Codes
.origin { width: 100px; height: 200px; background-color: red; transition: 0.5s ease-out;
}
.destination { width: 100px; height: 200px; background-color: blue; opacity: 0.7; position: absolute; top: 100px; right: 40px; transition: 0.5s ease-out;
}
Move - Script Codes JS Codes
function Zoomify( orig, dest ){ console.log( orig, dest ); var _this = this; this.origProps = this._getProps( orig ); this.destProps = this._getProps( dest ); this.diffs = this._getDiffs( this.origProps, this.destProps ); this.dest = dest; this.orig = orig;
};
Zoomify.prototype.refresh = function(){ this.origProps = this._getProps( this.orig ); this.destProps = this._getProps( this.dest ); this.diffs = this._getDiffs( this.origProps, this.destProps );
}
Zoomify.prototype._getDiff = function( a, b ){ return b - a;
};
Zoomify.prototype._getDiffs = function( o, d ){ var props = {}; props.translateX = this._getDiff( o.left, d.left ); props.translateY = this._getDiff( o.top, d.top ); props.scale = d.width / o.width; return props;
};
Zoomify.prototype._setProps = function( el, props ){ el.setAttribute( 'style', this._getTrans() + ':' + 'translateX(' + props.translateX + 'px) ' + 'translateY(' + props.translateY + 'px) ' + 'translateZ(0)' + 'scale(' + props.scale + ');' );
};
Zoomify.prototype._getProps = function( el ){ return el.getBoundingClientRect();
};
Zoomify.prototype._getEndEvt = function(){ var transEndEventNames = { 'WebkitTransition' : 'webkitTransitionEnd', // Saf 6, Android Browser 'MozTransition' : 'transitionend', // only for FF < 15 'transition' : 'transitionend' // IE10, Opera, Chrome, FF 15+, Saf 7+ }; return transEndEventNames[ Modernizr.prefixed('transition') ];
}
Zoomify.prototype._getTrans = function(){ var transNames = { 'WebkitTransform' : '-webkit-transform', 'webkitTransform' : '-webkit-transform', 'msTransform' : '-ms-transform', 'MozTransform' : '-moz-transform', 'transform' : 'transform' }; return transNames[ Modernizr.prefixed('transform') ];
}
//public methods
Zoomify.prototype.toOrig = function(){ var _this = this; this.orig.removeAttribute('style'); this.orig.classList.remove('c-gift--zoomed');
}
Zoomify.prototype.toDest = function(){ var _this = this; this._setProps( this.orig, this.diffs ); this.orig.classList.add('zooming'); this.orig.addEventListener( this._getEndEvt(), function(){ if( _this.orig.getAttribute( 'style' ) === null ) { _this.orig.classList.remove('zooming'); } else { _this.orig.classList.add('zoomed'); } });
}
var or = document.querySelector('.origin');
var dest = document.querySelector('.destination');
var Z = new Zoomify(or, dest );
or.addEventListener('click', () => Z.toDest() );
dest.addEventListener('click', () => Z.toOrig() )
Developer | James Crockford |
Username | james_crockford |
Uploaded | November 19, 2022 |
Rating | 3 |
Size | 2,484 Kb |
Views | 8,096 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Circular Profile | 2,689 Kb |
A Pen by James Crockford | 3,086 Kb |
Hexagon Split | 2,067 Kb |
Drips | 7,991 Kb |
Vim logo animated | 3,338 Kb |
Glow loading | 2,414 Kb |
Yank | 2,268 Kb |
Keys | 2,290 Kb |
Parallax background | 3,413 Kb |
Hexagon switch | 2,219 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
A Bouncy Menu Toggle | Billyysea | 4,563 Kb |
3D Text in Sass | Bookcasey | 2,766 Kb |
03 - CSS Variables | Run-time | 2,682 Kb |
Alter bg opacity on hover... | Chrisboon27 | 2,054 Kb |
Two column of responsive height | Fixie | 2,908 Kb |
Ghost Buttons with CSS3 | Mithicher | 2,509 Kb |
Planet Awesome | Bartuc | 3,554 Kb |
Bootstrap Responsive Menu Drawer | JesseGlacken | 3,777 Kb |
JavaScript Animation | Rcmeisty | 4,581 Kb |
Countdown Timer | Massiebn | 3,001 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!