Creating a small wiggle from a shake on a button - javascript

I am building my first site and really wanted a button which wiggled. I was doing some research and i found the perfect button that i want.
Link
If you scroll down to the end of the page. The way the download button looks is exactly what i wanted. However for some reason i been playing around with the code and i dont get any sort of animation to appear. No idea why this is. If possible could someone show me the way on how to code this?
Thanks
Sorry forgot the code:
#-webkit-keyframes wiggle {
0% {
-webkit-transform:rotate(4deg);
}
50% {
-webkit-transform:rotate(-4deg);
}
100% {
-webkit-transform:rotate(4deg);
}
}
.wiggle:hover {
-webkit-animation: wiggle 0.5s infinite;
}
This is not from the site, this is my trying , but it does not get the right effect which is the same as the download button. I am actually really stuck on this hahaha :) So any help on this would be great x

You could check their animations from here https://elrumordelaluz.github.io/csshake/css/csshake.css to get a clue.

Related

Is there any jQuery library for elements entrance animation while page scroll?

Any one know a good library for elements entering animation while page scrolling. I have used animate it library, its awesome, lite and easy to handle but not working with newest version of jQuery(3.x).
Somebody suggest me a good free library.
You may try animate-on-scroll:
https://michalsnik.github.io/aos/
Or if you need a more advanced library with lot more control in your hands, try ScrollMagic:
http://scrollmagic.io/
you can use Animate.css and Wow.js
You could use the onscroll event handler.
window.onscroll - function() {
var el = document.getElementById('animateMe');
el.addClass('anime');
}
where you have the animation included in the .anime class.
CSS
.anime {
animation: yourAnimation 2s ease-out;
}
#keyframes animation {
0% {
background: blue;
}
100% {
backgroudn: red;
}
}
If you need the animation to stop when not scrolling, see How do I know when I've stopped scrolling Javascript.

Loop colour transition with CSS

I would like to be able to loop a colour transition for the background colour of my website, so it slowly shifts between two subtly different hues as the users browse, to give variation to their browsing experience. I'm wanting something like the following:
.background {
background-color: #00A0D6;
transition: background-color: 100s;
}
But with background-color cycling back to #00A0D6, then beginning the transition back to #00B1D7 as soon as it has reached #00A0D6. I would also like this to happen automatically, from the moment a user browses to the site.
If possible I would like to do this in vanilla CSS. If not, is there a way to use a Javascript loop to cycle the value in this way? Possibly with the jQuery library? I would like the most processor-efficient method possible which still retains a smooth transition, since this is for an online RPG, which will be doing a lot of other transitions and databasing at the same time.
You can use CSS #keyframes to achieve what you want:
#keyframes changeColor {
from {
background-color: #00A0D6;
}
to {
background-color: #00B1D7;
}
}
Then you use it with the animation property in the desired elements:
html, body {
animation: changeColor 100s infinite alternate;
}
More on CSS Keyframes here.

Angular JS and Animate.css: fade animation is janky

I have a dialog in which I'd like to display one of two things depending on the state of a variable. So, I hooked up 2 versions of a form with ng-if.
When you click "delete" button on first state, it toggles to the second state.
I wanted to make it less abrupt, so I tried adding some css:
[ng-if].ng-enter {
animation: fadeIn .5s;
}
[ng-if].ng-leave {
animation: fadeOut .5s;
}
These animations come from the bower package "animate css":
#keyframes fadeIn {
0% {opacity: 0;}
100% {opacity: 1;}
}
.fadeIn {
animation-name: fadeIn;
}
However, as you can see in my animated GIF below, what happens is that for a second BOTH forms appear, making the dialog taller, then one fades out.
Is there no way to do a simple fadein/fadeout as in jQuery? I used to do this all the time with it, but trying to get nice UI animation in Angular is eluding me.
I had a similar problem with an Angular app and animations. I ended up having to use jquery - I wish I had a better answer - but it turned out beautifully. One note, though, I had to wrap any jquery I used in a noConflict() and use body on click plus the element because it doesn't exist yet in the DOM:
$.noConflict();jQuery( document ).ready(function( $ ) {
$('body').on('click', "#toggler", function(){
$('#div_to_show').slideDown();
});
});
I realize this a tangential answer and not an elegant solution but it worked for me to get it out the door under a tight deadline.
A clean solution is to change the state you use to check which form is to display when the animation ng-leave ends.
You can use a second variable to set the ng-leave class in the form that will be hidden.
I can't post you some code because i don't know your js and html.

Page to page fading effect

i need to implement load/unload page animations fade-in on load, and fade-out on unload.
1) I have read some articles about implementation it based on links clicks. That's does not work for me. I don't want to go that way, because some links should not open new page actually, and have href.
So imagine: link has properly href, but sometimes it open new page, sometimes not, based on it handler behavior. We add another handler that fire redirect all the time as timeout callback.
2) I can't implement animation using page unload event. I think it's right way.
Please help or advice something. Thank You!
Give your links you want to animate a class. Then you can use the .click() method to check when a link is clicked. Then do a preventDefault to stop the default behavior.
The next thing to do is check if there is "http" in the href attribute. You can get the value with $(this).attr('href');. If the link contains this, you need to go to a new page. For this, use window.location.href. Call this method as the callback of your fadeOut().
The only thing that is left is do a fade in when the page loads ;)
Actually i was finding the way without using links event, but using any UNLOAD event. Links events can be used only on a small website. In my case it created additional errors. For example some links, shouldn't do fade-out, and i don't know which of them actually.
So i don't recommend to do this. Need to find any UNLOAD page redirections animation way.
I'm not sure if I understand your question correctly..
Put this code in the pages' <head>s.
<style>
#keyframes page_transition
{
from {opacity: 0;}
to {opacity: 1;}
}
#-webkit-keyframes page_transition
{
from {opacity: 0;}
to {opacity: 1;}
}
html
{
animation: page_transition 1s ease-in-out;
-webkit-animation: page_transition 1s ease-in-out;
}
html.unloading
{
transition: opacity 500ms linear !important;
opacity: 0 !important;
}
</style>
<script>
window.addEventListener("beforeunload", function() {
document.documentElement.classList.add("unloading");
});
</script>

Glowing right angle quote animation with CSS3 and/or Javascript

I'm looking to make a clever animation that makes three sucessive right angle quotes like » » » glow successively from left to right, then back to the left-most one again. I'm wondering if this might be a clever effect for other developers to use as well, and could be good Google-fodder.
The inspiration for this is obviously the slide-to-unlock screen on an iPhone, where the text glows in a progressive manner.
I do know about CSS3 animations with keyframes and have implemented these successfully before, but am not sure how to code in the part with the loop. I'm guessing Javascript is the answer here, with some kind of loop. I already have jQuery on the page I'm using so it wouldn't be anything extra to use jQuery functionality.
My HTML structure would be something like this:
<span class="glowquote"><span>»</span> <span>»</span> <span>»</span></span>
Any ideas on the best/most clever way to implement this? I realize not all browsers support CSS3 animations if they are to be used and honey badger don't care, I only need to support modern webkit and gecko implementations.
Edit 1: added span tags around each » to allow changing CSS properties individually for each right angle quote in JavaScript, as most people have done. For the guy who did the CSS3 method, not necessary!
Edit 2: Just for absolute clarity on what the goal is, the left-most one will glow a certain color first, using a CSS color:green etc. change and transition:color linear 0.4s etc, then the next one will do the same right after with maybe a short delay.
Edit 3: For further clarification, the exact animation I'm looking for looks like this, though in the example they've used a VERY hack-ish method that I don't think will work for a lot of people. I'm wondering if we are just coming up against the limitations of javascript/css3 or if there is more refinement possible. Link: http://css-tricks.com/examples/SlideToUnlock/
FINAL EDIT WITH SOLUTION SUMMARY: I decided to go with the pure CSS3 option but there are many valid options presented here that are all worthy of your time. I wish StackOverflow would allow for more than one correct answer. For anyone coming to this question from Google or elsewhere, make sure to browse the whole question to choose what may work the best for you! I figured that since this is mostly just for fun, I would feel okay leaving the Firefox & IE guys out in the dark. You can see what my final implemention was here: http://ezrahub.com/board/ at the top of the page, where it is used to expand the posting form. One quirk is that if you change the text size, you will also have to change the property background-size in your CSS stylesheet. I used background-size: 120px 50%; for mine, and if you play around with it you can see how the effect changes.
Hope everyone has fun with this and enjoy using it on your creations! Shout out to autistic moderators such as #JaredFarrish. (Why so mad?)
For the fun of it, here is a method using pure css. It has very limited support for browsers.
.glowquote {
background: -webkit-linear-gradient(left, black 0%, green 40%, green 60%, black 100%);
background-size: auto 50%;
padding: 0 100px;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-animation: gradient-animation infinite 1s linear;
}
http://jsfiddle.net/grc4/uF8H2/3/
Edit: The jsfiddle now partly works in firefox. The gradient animation works correctly, and the only thing that does't work is the text clipping (-moz-background-clip:text doesn't exist). This could be solved by using an image mask over the top of the background.
First, I'd put spans around the individual arrows so that you can change their CSS settings individually:
<span class="glowquote"><span>»</span> <span>»</span> <span>»</span></span>
Then, assuming you're using jQuery UI (because as far as I know core jQuery won't animate colours) you can do something like the following:
function doGlow(numTimes) {
var $arrows = $("span.glowquote span");
function nextGlow(i) {
$arrows.eq(i).animate({
color: "green"
}, 400).animate({
color: "black"
}, 400, function() {
i = (i + 1) % $arrows.length;
if (i === 0) numTimes--;
if (numTimes > 0) nextGlow(i);
});
}
nextGlow(0);
}
Demo: http://jsfiddle.net/KrL44/1
(Or here is the original version of my demo that just kept looping indefinitely: http://jsfiddle.net/KrL44/)
try this:
html:
<span class="glowquote"><span>»</span> <span>»</span> <span>»</span> </span>
js:
$(document).ready(function(){
var i = 0;
function run() {
$('.glowquote span:eq('+ i +')').animate({color: 'green'}, 500, function(){
$(this).animate({color: 'black'}, 500);
i++;
if (i > 2) { i = 0 }
run()
})
}
run()
})
http://jsfiddle.net/wQ9AT/

Categories