Skip to content

Commit

Permalink
Use JS ratio helper to calculate ratio. Closes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainjule committed Nov 23, 2021
1 parent da8e28d commit 6d99bef
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion index.js

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

9 changes: 0 additions & 9 deletions lib/fields/imageradio.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@
return $mobile;
},
'ratio' => function($ratio = '1/1') {
$computed = 1;

if (preg_match('/(\d+)(?:\s*)([\/])(?:\s*)(\d+)/', $ratio, $matches) !== false){
$computed = $matches[3] / $matches[1];
}

$computed = $computed * 100;
$ratio = round($computed, 3, PHP_ROUND_HALF_DOWN);

return $ratio;
},
),
Expand Down
2 changes: 1 addition & 1 deletion src/components/field/ImageRadio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export default {

<style lang="scss">
@import '../../assets/css/styles.scss'
</style>
</style>
6 changes: 3 additions & 3 deletions src/components/input/ImageRadioInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default {
},
computed: {
padding() {
return 'padding-top:'+ this.ratio + '%;'
}
return 'padding-top:'+ this.$helper.ratio(this.ratio, 'auto', false)
},
}
}
</script>
</script>

0 comments on commit 6d99bef

Please sign in to comment.