summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-02-10 11:46:11 +0800
committereltrac <hi@eltr.ac>2026-02-10 11:46:11 +0800
commit22c624c43e234753a59830fb349842161554b94d (patch)
tree7af752cad9b05294277bffb949dd61f7131ccd87
parente5a5dd2e1e8d14237a155e40d6a2e15ba1f05dda (diff)
feat: add config 'zeroMarginBreakpoint'
-rw-r--r--src/animation.js6
-rw-r--r--src/config.js16
2 files changed, 16 insertions, 6 deletions
diff --git a/src/animation.js b/src/animation.js
index 5d9b5f5..85c6dd7 100644
--- a/src/animation.js
+++ b/src/animation.js
@@ -4,7 +4,11 @@ export default class Animation {
static calculateFinalState(element) {
let finals = {}
- const margin = config.margin;
+ let margin = config.margin;
+ if (window.innerWidth <= config.zeroMarginBreakpoint) {
+ margin = 0
+ }
+
const nw = element.naturalWidth;
const nh = element.naturalHeight;
const ratio = nw / nh;
diff --git a/src/config.js b/src/config.js
index c306d8f..2a64db1 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,9 +1,15 @@
const config = {
- selector: '[data-libra]',
- margin: 50,
- offset: { x: 0, y: 0 },
- transitionDuration: 200, // milliseconds
- imageCursor: 'zoom-in',
+ selector: '[data-libra]',
+ margin: 50,
+
+ // in small screens, it's best to not use margins
+ // otherwise, the zoomed image gets even smaller
+ // define on screen smaller than what size, margin is set to 0
+ zeroMarginBreakpoint: 768,
+
+ offset: { x: 0, y: 0 },
+ transitionDuration: 200, // milliseconds
+ imageCursor: 'zoom-in',
};
function deepMerge(target, source) {