Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Steck committed Sep 22, 2022
2 parents 8be85a8 + 6005419 commit 2b2f280
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"favorites.resources": [
{
"filePath": "examples/index.html",
"group": "Default"
},
{
"filePath": "src/bounty.js",
"group": "Default"
}
]
}
4 changes: 2 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
</head>

<body>
asdf
<div class="js-bounty"></div>
<div class="js-bounty2"></div>
<script src="../lib/bounty.js"></script>
<script>
const b = bounty.default({ el: '.js-bounty', value: '250000', rotations: '2', animationDelay: 0, startManually: true })
setTimeout(() => {
console.log('start')
b.resume()
}, 1000)
}, 500)
</script>
</body>

Expand Down
2 changes: 1 addition & 1 deletion lib/bounty.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"description": "SVG library for transitioning numbers with motion blur",
"main": "lib/bounty.js",
"scripts": {
"start": "webpack serve --progress --colors --inline --host 0.0.0.0",
"dev": "webpack serve --progress --colors --inline --host 0.0.0.0",
"build": "webpack -p",
"test": "echo \"Error: no test specified\" && exit 1",
"start:dev": "webpack serve"
"test": "echo \"Error: no test specified\" && exit 1"
},
"files": [
"lib/*.js"
Expand Down
27 changes: 17 additions & 10 deletions src/bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export default ({
letterAnimationDelay = 0,
duration = 3000,
rotations = 1,
startManually = false
startManually = false,
motionBlur = true
}) => {
const element = select(el)
const computedStyle = window.getComputedStyle(element)
Expand Down Expand Up @@ -170,15 +171,21 @@ export default ({
digit.node:: attr(
"transform",
`translate(${digit.offset.x}, ${digit.offset.y})`
)
const filterOrigin = (sourceDistance + targetDistance) / 2
const motionValue = Number(
Math.abs(
Math.abs(Math.abs(value - filterOrigin) - filterOrigin) -
sourceDistance
) / 100
).toFixed(1)
digit.filter:: attr("stdDeviation", `0 ${motionValue}`)
);
let motionValue
if(motionBlur) {
const filterOrigin = (sourceDistance + targetDistance) / 2;
motionValue = Number(
Math.abs(
Math.abs(Math.abs(value - filterOrigin) - filterOrigin) -
sourceDistance
) / 100
).toFixed(1);
} else {
motionValue = 0
}

digit.filter::attr("stdDeviation", `0 ${motionValue}`);
},
end:
i === 0
Expand Down

0 comments on commit 2b2f280

Please sign in to comment.