Skip to content

Angle to rotate #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/.vuepress/components/DemoElegantTriangles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
shape: 'polygon',
duration: 1160,
radius: { 60: 65 },
angle: -60,
rotate: -60,
fill: 'none',
stroke: COLORS.white,
strokeWidth: { 30 : 5 },
Expand All @@ -52,7 +52,7 @@
shape: 'polygon',
duration: 1160,
radius: 14,
angle: -60,
rotate: -60,
fill: 'none',
stroke: COLORS.white,
strokeWidth: { 14 : 4 },
Expand Down Expand Up @@ -84,7 +84,7 @@
shape: 'polygon',
duration: 1000,
radius: { 40: 20 },
angle: -60,
rotate: -60,
fill: 'white',
fillOpacity: { 0: 1 },
stroke: COLORS.white,
Expand Down
283 changes: 147 additions & 136 deletions docs/.vuepress/components/DemoExpandingCircles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,156 +2,167 @@
<template>
<div class="mojs-interactive">
<slot></slot>
<div class="mojs-interactive__result" id="demo-expanding-circle" style="background: rgb(241, 226, 215); height: 600px">
<div id="demo-expanding-circle_controller" class="mojs-interactive__controller"></div>
<div
class="mojs-interactive__result"
id="demo-expanding-circle"
style="background: rgb(241, 226, 215); height: 600px"
>
<div
id="demo-expanding-circle_controller"
class="mojs-interactive__controller"
></div>
</div>
</div>
</template>

<script>
export default {

mounted: function () {
import('@mojs/core').then(module => {
import('@mojs/player').then(module => {


const COLORS = {
bg: 'rgb(241, 226, 215)',
accent: '#3A0839',
export default {
mounted: function () {
import("@mojs/core").then((module) => {
import("@mojs/player").then((module) => {
const COLORS = {
bg: "rgb(241, 226, 215)",
accent: "#3A0839",
};

const _getWindowSize = () => {
const w = window;
return Math.max(
w.innerHeight || e.clientHeight || g.clientHeight,
w.innerWidth || e.clientWidth || g.clientWidth
);
};

const _calcScale = (radius) => {
return 1.4 * (_getWindowSize() / radius / 2);
};

let circleSize = 500,
scale = _calcScale(circleSize),
opts = {
parent: "#demo-expanding-circle",
radius: circleSize,
fill: COLORS.accent,
scale: { 0.05: 0.2 },
duration: 465,
easing: "cubic.out",
isShowEnd: false,
isForce3d: true,
};

const _getWindowSize = () => {
const w = window;
return Math.max( (w.innerHeight || e.clientHeight || g.clientHeight), (w.innerWidth || e.clientWidth || g.clientWidth) )
}

const _calcScale = (radius) => {
return 1.4 * (_getWindowSize() / radius / 2);
}

let circleSize = 500,
scale = _calcScale( circleSize ),
opts = {
parent: '#demo-expanding-circle',
radius: circleSize,
fill: COLORS.accent,
scale: { 0.05 : 0.2 },
duration: 465,
easing: 'cubic.out',
isShowEnd: false,
isForce3d: true,
};

const circle1 = new mojs.Shape(opts)
.then({
easing: 'cubic.inout',
scale: .125,
duration: 350
}).then({
easing: 'cubic.inout',
scale: scale,
duration: 465
});

const circle2 = new mojs.Shape({
...opts,
fill: COLORS.bg,
scale: { 0 : .1125 },
duration: 407,
delay: 580
}).then({
easing: 'cubic.inout',
scale: scale,
duration: 350
});

const circle3 = new mojs.Shape({
...opts,
scale: { 0: scale },
duration: 580,
delay: 1160,
isShowStart: false,
isShowEnd: true
});

const smallCircle = new mojs.Shape({
parent: '#demo-expanding-circle',
radius: { 5: 25 },
fill: 'none',
stroke: COLORS.accent,
strokeWidth: { 20: 0 },
isShowEnd: false,
delay: 700,
duration: 290,
const circle1 = new mojs.Shape(opts)
.then({
easing: "cubic.inout",
scale: 0.125,
duration: 350,
})
.then({
easing: "cubic.inout",
scale: scale,
duration: 465,
});

const triangleOpts = {
parent: '#demo-expanding-circle',
shape: 'polygon',
radius: 15,
duration: 407,
fill: COLORS.bg,
y: { 80 : -15 },
scale: { 1 : 0 },
delay: 495,
isForce3d: true,
easing: 'cubic.out'
}
const triangle1 = new mojs.Shape( triangleOpts );

const triangle2 = new mojs.Shape({
...triangleOpts,
y: { [-80] : 15 },
angle: 180
});

const lineOpts = {
parent: '#demo-expanding-circle',
shape: 'line',
x: -180,
radius: 50,
radiusY: 0,
stroke: COLORS.accent,
strokeWidth: {15 : 0},
duration: 580,
isShowEnd: false,
strokeDasharray: '100% 100%',
strokeDashoffset: { '-100%': '100%' },
easing: 'cubic.out',
}
const line1 = new mojs.Shape(lineOpts);
const circle2 = new mojs.Shape({
...opts,
fill: COLORS.bg,
scale: { 0: 0.1125 },
duration: 407,
delay: 580,
}).then({
easing: "cubic.inout",
scale: scale,
duration: 350,
});

const line2 = new mojs.Shape({
...lineOpts,
angle: 180,
x: -lineOpts.x
});
const circle3 = new mojs.Shape({
...opts,
scale: { 0: scale },
duration: 580,
delay: 1160,
isShowStart: false,
isShowEnd: true,
});

this.timeline = new mojs.Timeline();
this.timeline
.add(
circle1, circle2, circle3, smallCircle,
triangle1, triangle2,
line1, line2
);
const smallCircle = new mojs.Shape({
parent: "#demo-expanding-circle",
radius: { 5: 25 },
fill: "none",
stroke: COLORS.accent,
strokeWidth: { 20: 0 },
isShowEnd: false,
delay: 700,
duration: 290,
});

const parentDOM = document.getElementById('demo-expanding-circle_controller');
new MojsPlayer({
add: this.timeline,
isPlaying: false,
isRepeat: false,
parent: parentDOM,
name: "demo-expanding-circle_controller",
className: 'controller',
isSaveState: false,
isHidden: false,
});
const triangleOpts = {
parent: "#demo-expanding-circle",
shape: "polygon",
radius: 15,
duration: 407,
fill: COLORS.bg,
y: { 80: -15 },
scale: { 1: 0 },
delay: 495,
isForce3d: true,
easing: "cubic.out",
};
const triangle1 = new mojs.Shape(triangleOpts);

const triangle2 = new mojs.Shape({
...triangleOpts,
y: { [-80]: 15 },
rotate: 180,
});

const lineOpts = {
parent: "#demo-expanding-circle",
shape: "line",
x: -180,
radius: 50,
radiusY: 0,
stroke: COLORS.accent,
strokeWidth: { 15: 0 },
duration: 580,
isShowEnd: false,
strokeDasharray: "100% 100%",
strokeDashoffset: { "-100%": "100%" },
easing: "cubic.out",
};
const line1 = new mojs.Shape(lineOpts);

const line2 = new mojs.Shape({
...lineOpts,
rotate: 180,
x: -lineOpts.x,
});

this.timeline = new mojs.Timeline();
this.timeline.add(
circle1,
circle2,
circle3,
smallCircle,
triangle1,
triangle2,
line1,
line2
);

const parentDOM = document.getElementById(
"demo-expanding-circle_controller"
);
new MojsPlayer({
add: this.timeline,
isPlaying: false,
isRepeat: false,
parent: parentDOM,
name: "demo-expanding-circle_controller",
className: "controller",
isSaveState: false,
isHidden: false,
});
});

},
}
});
},
};
</script>
Loading