Move

Size
2,484 Kb
Views
8,096

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 Previews

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() )
Move - Script Codes
Move - Script Codes
Home Page Home
Developer James Crockford
Username james_crockford
Uploaded November 19, 2022
Rating 3
Size 2,484 Kb
Views 8,096
Do you need developer help for Move?

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!

James Crockford (james_crockford) Script Codes
Create amazing sales emails with AI!

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!