Does anyone know how to implement linear animation, for example like in progress bars, where few of lines moving infinite in the bar from left to right or any other way? I'm going to use only QtQuick2 primitives and without any additional C++ components, glad to see any answers that can fit this requirements. Also, I know how to set infinite loop for animation, but actual question is to how moves row of rectangles/lines from letf to right in infinity loop, I just can't imagine approach for that.
Something like that?
Rectangle {
width: 400
height: 30
anchors.centerIn: parent
border.color: "grey"
border.width: 1
clip: true
Rectangle {
id: runner
property double percent: 0.2
width: parent.width * percent
height: parent.height
color: "orange"
NumberAnimation on x { from: runner.width * (-1); to: 400; duration: 2000; loops: Animation.Infinite }
}
}
Related
Problem:
So, made a digital story with illustrations. I pieced it all together by using simple waapi css animations, that gives a parallax effect. Problem with my code is that all my content/images is placed on a timeline in relation to a offset value between 0 and 1. This makes the whole story blast trough in one fast scroll motion on the trackpad/scrollwheel :(
Tried various css and js methods to smooth and slow down the scroll without luck.
How can I best write this so the scroll is slowed down?
Demo (Best in 1440px900px window): https://andyradall.github.io/andylax/
Source code git: https://github.com/Andyradall/andylax
Source code in Jsfiddle: https://jsfiddle.net/Andyradall/yLvboa6t/8/
Example of javascript code for one of the images:
// Settings for animations length
const animasjonSettings = {
duration: 12000,
fill: "both"
}
// Settings for one of the images
const tekstboks3 = document.querySelector("#tekstboks3");
const tekstboks3Keyframes = [
{top: "2.5rem", left: "-22rem", opacity: 1.0},
{top: "2.5rem", left: "-22rem", opacity: 1.0, offset: 0.41},
{top: "2.5rem", left: "3rem", opacity: 1.0, offset: 0.46},
{top: "2.5rem", left: "3rem", opacity: .01, offset: 0.7},
{top: "2.5rem", left: "3rem", opacity: .01,}
];
const tekstboks3Animasjon = tekstboks3.animate(tekstboks3Keyframes, animasjonSettings);
// Start all animations in array on scroll
function animerAlle() {
const y = scrollY;
for(const animasjon of animasjoner) {
animasjon.currentTime = y * 3;
}
}
document.addEventListener("scroll", animerAlle);
I'm not 100% sure since i don't have a tactile device, but I could make the scroll longer (and thus, slower) only by changing these two properties of your code (multiplying by 2 but you can try other operations...)
/* index.css */
body {
height: 1530vh; /* 765 * 2 = 1530 */
background: #7DD3E2;
}
// index.js
// Innstilling for animasjonslengde
const animasjonSettings = {
duration: 24000, // 12000 * 2 = 24000
fill: "both"
}
don't know if it's what you want...
Besides, really good job your site is amazing!
[edit]
for the smooth part, you can look into scroll-snap property but I fear it would make more harm than good
Our app includes a screen where there is a large circle in the background which changes position. It's mostly absolute positioning using this sort of style. The circle changes to use the right style and animates into the new position underneath some tutorial text.
const { height, width } = Dimensions.get('screen')
const circleRadius = isIphoneX() ? height * 0.55 : height * 0.60
export const styles = StyleSheet.create({
circleMassiveLeft: {
position: 'absolute',
backgroundColor: primary,
width: circleRadius * 2,
height: circleRadius * 2,
borderRadius: circleRadius,
left: -circleRadius + width - 50,
top: -circleRadius + height / 2
},
circleMassiveRight: {
position: 'absolute',
backgroundColor: primary,
width: circleRadius * 2,
height: circleRadius * 2,
borderRadius: circleRadius,
left: -circleRadius + 50,
top: -circleRadius + height / 2
}
})
This has been working great to display the circle in the correct position across multiple display sizes. Since it needs to be so precisely positioned, using absolute positioning seems to be a better solution than flex in this case. Our challenge is that when changing the system settings in Android to display size small, the circle becomes smaller. Of course, that makes sense in a way, but this particular element looks pretty awful because of the layout of the rest of the screen when it's resized to be smaller. Elements that used to be on top of it are now poking out! Is there a way to make sure that this element displays at the same size regardless of Android system display size settings? Poking around the docs, there doesn't seem to be a basic setting for this.
Try to use www.npmjs.com/package/react-native-responsive-dimensions
read this
In the article they using: react-native-size-matters
I'm trying to remove the gaps between the bars in Highcharts with the {pointWidth: 30} option defined, using {pointPadding: 0, groupPadding: 0, borderWidth: 0} has no effect. (see JSFiddle)
How do I achieve the following result without the gaps:
Thanks in advance.
Highchart does not seems to calulate padding on x-axis after pointWidth is defined. Refer
https://api.highcharts.com/highcharts/series.column.pointWidth. Not sure if that limitation Highchart.
Although, it not perfect solution, I tried to do using css3 (scss) to position the bar. The solution is quite odd.
Please have a look and hopefully you can come up with better idea than this one.
https://jsfiddle.net/6f9yvcan/105
SCSS
$columns-list: 1 3 5 7 9 11 13;
$column-left-offset: 200px;
#each $col in $columns-list {
$i: index($columns-list, $col);
$column-left: (30px * $i) + $column-left-offset;
.highcharts-series:nth-child(#{$col}) {
rect {
x: $column-left;
}
}
.highcharts-data-labels:nth-child(#{$i}) .highcharts-data-label {
background-color: red;
left: ($column-left - 20px) !important;
}
}
I just came across this wonderful product and realized this is exactly what I need! I have a huge image that is x times the window size, so I want to scroll to the very bottom of it on button click. I would do so with CSS like this:
#keyframes {
to {
transform: translateY(-100%) translateY(100vh);
}
}
This proved to be a crossbrowser way in CSS instead of:
transform: translateY(calc(-100% + 100vh));
Is there any way to do so with TweenMax? I do understand that I can calculate these values in pixels and specify them explicitly:
var value = -$('img').height() + $(window).height();
var tweenDown = TweenMax.to("img", 5, {y: value});
However the advantage of the "stacked" way is that when you resize the window, it keeps the image in the same position.
Thanks in advance!
This is what I came up with for those wondering:
TweenMax.to('img', 5, {
transform: 'translate3d(0,100vh,0)',
percentY: -100
});
[My solution to the bottom]
Actually, with current version of GSAP I think this would be
TweenMax.to('img', 5, {
y: '100vh',
yPercent: -100
});
But, the 'the notes about transforms' documentation section says
To do percentage-based translation use xPercent and yPercent (added in version 1.13.0) instead of x or y which are typically px-based
https://greensock.com/docs/Plugins/CSSPlugin
Judging by the above,
I think 100vh for y would be interpreted as 100px when added in the css matrix property. In order for this to fully work, I opted for the following:
TweenMax.to('img', 5, {
y: window.innherHeight, // or $(window).heigth()
yPercent: -100
});
I find this website -> http://bit.ly/1FCtQSQ and he has this animation scroll, which I am not interested, however in the middle of the scroll animation, a text snake animation appears. I want very badly to know how I can do this, just to learn.
I researched all plugins that curve texts, such as:
Arctext.js
CircleType
This one
Also, i tried 'still' the code from http://bit.ly/1FCtQSQ, but is minified, i know this guys are using the timelinemax, which uses the canvas, i tried to copy the code, but didn't work, as you can see here in the bottom of this question.
So i came here as the last resource.
Could someone give me an explanation with a working example, or maybe a plugin which i can study the code?
I know this is not the best way to find a answer to my question, but i don't have money to pay for codementor, hackhands, airpair or something like this.
Thanks!
Pen: http://codepen.io/anon/pen/GJjjxG
Code that i copy:
<h1 class="snake">Animate this like a snake!</h1>
var animation = new TimelineMax({
paused: !0,
ease: Linear.easeNone
});
var T = 0;
var f = 30;
animation.add(
TweenMax.to(e(".snake").parent(), f, {
left: -5e3
}), T);
Thanks.
The KonvaJS (formerly KineticJS) canvas library has some nice text-along-path code with a liberal MIT license:
https://github.com/konvajs/konva/blob/f6e2cf19a30dec2f94f50152f20c35988b1bf99e/src/plugins/TextPath.js
The KonvaJS TextPath code works like this:
Start with a path made up of curves and lines defined using the same syntax that SVG uses to define path.
Calculate waypoints along that path.
Fit characters one-by-one along the path using the calculated waypoints.
Use transformations to position the characters properly. (using context.translate & context.rotate to match the letter to the angle of the path / curve.)
You can cause the text to animate along the curve by beginning the text further & further beyond the first waypoint on the curve.
Example code using the KonvaJS libarary:
var stage = new Konva.Stage({
container: 'container',
width: 1000,
height: 1000
});
var layer = new Konva.Layer();
// add the layer to the stage
stage.add(layer);
var textpath = new Konva.TextPath({
x: 0,
y: 50,
fill: '#333',
fontSize: 16,
fontFamily: 'Arial',
text: 'Now is the time for all good men to come to the aid of their party -- An phrase from an old touch-typing test.',
data: 'M 100 200 C 200 100 300 0 400 100 C 500 200 600 300 700 200 C 800 100 900 100 900 100'
});
layer.add(textpath);
layer.draw();
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #F0F0F0;
}
<script src="https://cdn.rawgit.com/konvajs/konva/0.9.0/konva.min.js"></script>
<div id="container"></div>