How do i animate on mouse over in Elm-UI? - animation

I would like a simple wipe when hovering over a button. I figured out to use mouseOver to change the background on hover, but I am not sure how to create a wipe from one background to another.
I am aware of elm-simple-animation, but I am too new to Elm to understand the docs..
Thanks!

This is surprisingly involved and part of it is I suspect that a proper transition library specifically designed around elm-ui is (AFAICT) still missing.
The basics steps are like this:
Define properties for the start and mouseOver states.
Figure out which properties these correspond to in elm-simple-animation.
Add a transition for those.
Element.Input.button
[ Background.color (Element.rgb 0.5 0.5 0.6)
, Element.mouseOver
[ Background.color (Element.rgb 0.7 0.7 1)
]
, Transition.properties
[ Transition.backgroundColor 500 []
]
|> Element.htmlAttribute
]
{ onPress = Nothing
, label = Element.text "Hello"
}
You can see a working example here.

Related

trigger built-in javascript animations provided by Divi theme when content becomes visible in the browser

I build WordPress sites using the Divi theme from Elegant Themes.
This theme provides a lot of visual modules to build your pages, and some of these modules have built-in animations.
For instance, the circle counter module displays a number with an animated circle around it, a percentage of the circle being colored based on the number displayed within the circle.
The animation plays when you scroll the page and when the circle counter module becomes visible in the browser.
I would like to know if I can use the browser development tools, and how, to find out how the animation is played, so I can trigger it whenever I want from my own scripts.
I also have access to the source code of the theme, but I don't know how to start to find what I am looking for.
And Divi support says "I am afraid that this feature is not supported. It would require customization which goes beyond the level of support that we can provide here.", so this is why I am here.
The circle version below will update during page load but the gauge doesn't adjust after that - only the number value changes. Passing a 'newval' to a progress bar will step up or down as necessary.
$(".et_pb_circle_counter_0").animate({
'data-width': newval
},{
duration: 1000,
specialEasing: {
width: 'linear'
},
step: function (now) {
$(".et_pb_circle_counter_0 .et_pb_circle_counter_inner").attr("data-number-value", newval );
$(".et_pb_circle_counter_0 span.percent-value").html( Math.ceil(now) );
}
});
// Progress Bars
$(".et_pb_counter_0 span.et_pb_counter_amount").animate({
width: newval+"%"
},{
duration: 1500,
specialEasing: {
width: 'linear'
},
step: function (now) {
$(".et_pb_counter_0 span.et_pb_counter_amount").attr("data-width", Math.ceil(now) + "%");
$(".et_pb_counter_0 span.et_pb_counter_amount_number").attr("data-width", Math.ceil(now) + "%");
$(".et_pb_counter_0 span.et_pb_counter_amount_number").html(Math.ceil(now) + "%");
}
});

How can i set the x axis tick interval to be 1 in C3 / d3 js charts?

I'm very new to chart building with c3 and d3. I've done a search, but I can't find an answer - could anyone help? how can I force the x axis to display every tick mark - it is currently displaying every other one. I want the chart to be dynamic, so I don't want to have to hard wire in the tick count (it is pulling data from elsewhere).
I hope I've made sense! Grateful for any suggestions.
You need to adjust culling option:
axis: {
x: {
tick: {
culling: false
}
}
}
See docs.
Also, you can force visibility of first and last tick value with little css hack:
.c3-axis-x g.tick:nth-last-child(2) text,
.c3-axis-x g.tick:nth-child(2) text {
display: block !important;
}

angular 2 animation is not working as expected

I am using angular 2 rc6 and I would like to have page transitions based on the route path. I am applying the following animation on two paths (as a test). I just want to animate the opacity and nothing else. But no matter what I do, I am unable to stop the page from translating on Y axis. The only option that I found which seemed to work is using style.position: absolute for host. I don't want to use that as that screws the position of all the elements on the page. I have also tried having just opactiy without the transform. That didn't work either.
host: {
'[#routeAnimation]': 'true',
'[style.display]': "'block'"
},
animations: [
trigger('routeAnimation', [
transition('void => *', [
style({opacity: 0, transform: 'translatey(0)'}),
animate('0.2s')
]),
transition('* => void', [
animate('0.2s', style({opacity: 0, transform: 'translatey(0)'}))
])
])
]
I am sure i am missing something here. not quite sure what? Thanks for the help.
1) As you can see you spelled transteY incorrectly the value of transform X or Y.
style({opacity: 0, transform: 'translatey(0)'}),
Should be uppercase like so:
style({opacity: 0, transform: 'translateY(0)'}),
2) Another thing I see in your code is that you binded your animation selector like so: [#routeAnimation]': 'true' if you used this selector exactly like this on your html you could never turn it on by toggling a boolean for example, try using a boolean like isMovingY = 'false' and place it in the selector like so [#routeAnimation]': isMovingY now when you toggle it with a click for example it could activate the "enter" / "leave" states you declared in the animation.

SVG performance drop when animating 2 or more elements, RaphaelJS

I am testing SVG performance using RaphaelJS library.
My code works, can be found here: JSFiddle
When you type in textbox "1" and press "add", a rectangle will be generated on screen and 4 animations will loop on it- moving right, down, left, up (also rotating, scaling and changing colour).
Performance seems to be ok. But add another element on stage and the performance gets knocked down to minimum in 3-4 seconds. Checked in Chrome timeline, the thing that is getting stacked up is "Animation Frame Fired - > Install Timer".
Perhaps I am doing loop incorrectly? Altough next animation starts when the previous ends, through callback function. Or is it Raphael itself? Should I try doing this with SVG and SMIL? (Raphael uses VML)
Any ideas?
------------------------------------UPDATE--------------------------------------
With RaphaelJS I did bad animation loop hooks, see answer below.
But another problem that does occur - add 1 element 10 times and you can see how animations get distorted, not finishing their full cycle, or add 10 elements 1 time and after few seconds you can see delayed animations on some of the elements.
I made SMIL version JSFiddle (no Raphael here), animations do not lag, delay, but they get syncronized. Can anyone explain why? And how to make those animations NOT sync, but unique?
I think the problem is you are recursively calling animations on a set.
So at the end of each animation, each element in the set calls an animation for the set again, so it spirals and grinds to a halt. You can get around this, by using 'this' instead of the set 'rectangles'.
//define 4 animations
var move_up = Raphael.animation({fill: "green", transform: "t0,0r360s1,1"}, 400, function(){ this.attr({"transform" : "t0,0"}); this.animate(move_right); });
var move_left = Raphael.animation({fill: "yellow", transform: "t0,100r270s0.5,0.5"}, 400, function(){ this.animate(move_up); });
var move_down = Raphael.animation({fill: "red", transform: "t100,100r180s1,1"}, 400, function(){ this.animate(move_left); });
var move_right = Raphael.animation({fill: "blue", transform: "t100,0r90s1.5,1.5"}, 400, function(){this.animate(move_down); });
jsfiddle

Why does the locator look semi-transparent in this Dynamic graphic?

I want a position a locator on a graphic, and update its position based on the mouse position. Here is some sample code:
Show[{
Graphics[{Yellow, Rectangle[]}],
Graphics[Dynamic[
With[{pt = MousePosition[{"Graphics", Graphics}]},
{ If[pt===None, ,Locator[pt^2]], Text[pt, {0,0}, {-1,-1}] }
]
]]
}, PlotRange -> {{-.2, 1.2},{-.2, 1.2}}]
The weird thing is that sometimes the locator displays normally, sometimes it displays at what looks like half opacity. It flips from normal to half-opacity as I move the mouse around.
Why is this, and what can I do to fix it?
I'm using Mathematica 8 on OSX.

Resources