Editing
User
:
Toad64/Homepage
Give feedback
Jump to navigation
Jump to search
Warning:
You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more
.
Log in
or
create an account
to continue receiving notifications after this account expires, and to access other features.
Anti-spam check. Do
not
fill this in!
<h3>Herocard design idea</h3> <p>This javascript code adds a listener to the <code>.HeroCard</code> element to allow the card the mouse is currently hovered over to tilt based on the mouse's location, relative to the center of the card:</p> <syntaxhighlight lang="javascript"> document.querySelectorAll('.HeroCard').forEach(function(el) { el.style.transition = 'none'; el.style.transformStyle = 'preserve-3d'; el.style.willChange = 'transform'; var animFrame; var current = { x: 0, y: 0 }; var target = { x: 0, y: 0 }; var mouseX = 0, mouseY = 0; var isOver = false; var rect = {}; var updateMouse = function(e){ mouseX = e.clientX; mouseY = e.clientY; } var tick = function() { var cx = rect.left + rect.width / 2; var cy = rect.top + rect.height / 2; var dx = (mouseX - cx) / (rect.width / 2); var dy = (mouseY - cy) / (rect.height / 2); target.x = dy * -12; target.y = dx * 12; current.x += (target.x - current.x) * 0.12; current.y += (target.y - current.y) * 0.12; el.style.transform = 'perspective(400px) rotateX(' + current.x + 'deg) rotateY(' + current.y + 'deg) scale(' + (isOver ? 1.05 : 1) + ')'; animFrame = requestAnimationFrame(tick); }; el.addEventListener('mouseenter', function() { rect = el.getBoundingClientRect(); // Measure ONCE document.addEventListener('mousemove', updateMouse); animFrame = requestAnimationFrame(tick); // Ignition }); el.addEventListener('mouseleave', function() { document.removeEventListener('mousemove', updateMouse); cancelAnimationFrame(animFrame); // Kill the engine el.style.transition = 'transform 0.5s ease-out'; el.style.transform = 'perspective(400px) rotateX(0deg) rotateY(0deg) scale(1)'; setTimeout(function() { el.style.transition = 'none'; }, 500); }); }); </syntaxhighlight> Using some css code, the background of the Hero Card can its background change when hovered (if not blocked behind the hero image).<syntaxhighlight lang="css"> .HeroCard .CardBacker { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 1; background-image: url("/images/1/1c/Card_backer.png"); background-size: 100% 100%; background-repeat: no-repeat; opacity: 0; transition: opacity 0.2s ease, filter 0.2s ease; filter: brightness(0) saturate(100%) invert(74%) sepia(35%) saturate(620%) hue-rotate(114deg) brightness(91%) contrast(89%); } .HeroCard:hover .CardBacker { opacity: 1; } .HeroCard .HeroImage, .HeroCard .HeroName { position: relative; z-index: 2; } </syntaxhighlight> <templatestyles src="User:Toad64/styles.css"/> <p> You can see the javascript code in action by clicking [https://deadlock.wiki/User:Toad64/Sandbox?withJS=User:Toad64/common.js Here] (desktop required).</p> {{Deadlock Wiki/Heroes}}
Summary:
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Deadlock:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Pages included on this page:
User:Toad64/styles.css
(
edit
)
Template:Deadlock Wiki/Heroes
(
view source
) (⧼restriction-level-moderator⧽)
Template:Hero Navbox
(
edit
)
Template:Hero Navbox/styles.css
(
edit
)
Template:Hero card2
(
edit
)
Template:Hero card2/styles.css
(
edit
)
Template:If lang
(
view source
) (⧼restriction-level-bot+⧽)
Template:MissingValveTranslationTooltip
(
edit
)
Template:Tooltip
(
edit
)
Module:Dictionary
(
edit
)
Module:HeroData
(
edit
)
Module:HeroData/nav
(
edit
)
Module:HeroData/release
(
edit
)
Module:Lang
(
edit
)
Module:Utilities
(
edit
)
Data:Dictionary
(
edit
)
Data:HeroData.json
(
view source
) (⧼restriction-level-bot+⧽)
Data:LangCodes.json
(
view source
) (⧼restriction-level-bot+⧽)
Data:Lang en.json
(
view source
) (⧼restriction-level-bot+⧽)
Navigation menu
Personal tools
Create account
Log in
associated-pages
User page
Discussion
English
Views
Read
Edit
Edit source
History
Tools
Search
Discord
Discord
Navigation
Main page
About us
Random page
Special pages
Recent changes
The Archmother/Voice lines
23m ago
·
Brewffee
Billy
35m ago
·
~2026-ReturnLightInfernus1079
Weapon Damage
3h ago
·
~2026-SpiritNeutralsWall1063
Headshot Booster
3h ago
·
~2026-SpiritNeutralsWall1063
Show more...
Interface Admin
Common CSS
Vector CSS
Minerva CSS
Citizen CSS
Brown theme CSS
Gadgets
Gadgets definition
Editing
How to edit
Style guide
All guides
New files
Unresolved feedback
Tools
What links here
Related changes
User contributions
Logs
View user groups
Page information
View buckets