biketrack-app/node_modules/.vite/deps/svelte_motion.js.map

8 lines
11 KiB
Plaintext

{
"version": 3,
"sources": ["../../svelte/motion/index.mjs"],
"sourcesContent": ["import { writable } from '../store/index.mjs';\nimport { now, loop, assign } from '../internal/index.mjs';\nimport { linear } from '../easing/index.mjs';\n\nfunction is_date(obj) {\n return Object.prototype.toString.call(obj) === '[object Date]';\n}\n\nfunction tick_spring(ctx, last_value, current_value, target_value) {\n if (typeof current_value === 'number' || is_date(current_value)) {\n // @ts-ignore\n const delta = target_value - current_value;\n // @ts-ignore\n const velocity = (current_value - last_value) / (ctx.dt || 1 / 60); // guard div by 0\n const spring = ctx.opts.stiffness * delta;\n const damper = ctx.opts.damping * velocity;\n const acceleration = (spring - damper) * ctx.inv_mass;\n const d = (velocity + acceleration) * ctx.dt;\n if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {\n return target_value; // settled\n }\n else {\n ctx.settled = false; // signal loop to keep ticking\n // @ts-ignore\n return is_date(current_value) ?\n new Date(current_value.getTime() + d) : current_value + d;\n }\n }\n else if (Array.isArray(current_value)) {\n // @ts-ignore\n return current_value.map((_, i) => tick_spring(ctx, last_value[i], current_value[i], target_value[i]));\n }\n else if (typeof current_value === 'object') {\n const next_value = {};\n for (const k in current_value) {\n // @ts-ignore\n next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);\n }\n // @ts-ignore\n return next_value;\n }\n else {\n throw new Error(`Cannot spring ${typeof current_value} values`);\n }\n}\nfunction spring(value, opts = {}) {\n const store = writable(value);\n const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;\n let last_time;\n let task;\n let current_token;\n let last_value = value;\n let target_value = value;\n let inv_mass = 1;\n let inv_mass_recovery_rate = 0;\n let cancel_task = false;\n function set(new_value, opts = {}) {\n target_value = new_value;\n const token = current_token = {};\n if (value == null || opts.hard || (spring.stiffness >= 1 && spring.damping >= 1)) {\n cancel_task = true; // cancel any running animation\n last_time = now();\n last_value = new_value;\n store.set(value = target_value);\n return Promise.resolve();\n }\n else if (opts.soft) {\n const rate = opts.soft === true ? .5 : +opts.soft;\n inv_mass_recovery_rate = 1 / (rate * 60);\n inv_mass = 0; // infinite mass, unaffected by spring forces\n }\n if (!task) {\n last_time = now();\n cancel_task = false;\n task = loop(now => {\n if (cancel_task) {\n cancel_task = false;\n task = null;\n return false;\n }\n inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);\n const ctx = {\n inv_mass,\n opts: spring,\n settled: true,\n dt: (now - last_time) * 60 / 1000\n };\n const next_value = tick_spring(ctx, last_value, value, target_value);\n last_time = now;\n last_value = value;\n store.set(value = next_value);\n if (ctx.settled) {\n task = null;\n }\n return !ctx.settled;\n });\n }\n return new Promise(fulfil => {\n task.promise.then(() => {\n if (token === current_token)\n fulfil();\n });\n });\n }\n const spring = {\n set,\n update: (fn, opts) => set(fn(target_value, value), opts),\n subscribe: store.subscribe,\n stiffness,\n damping,\n precision\n };\n return spring;\n}\n\nfunction get_interpolator(a, b) {\n if (a === b || a !== a)\n return () => a;\n const type = typeof a;\n if (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) {\n throw new Error('Cannot interpolate values of different type');\n }\n if (Array.isArray(a)) {\n const arr = b.map((bi, i) => {\n return get_interpolator(a[i], bi);\n });\n return t => arr.map(fn => fn(t));\n }\n if (type === 'object') {\n if (!a || !b)\n throw new Error('Object cannot be null');\n if (is_date(a) && is_date(b)) {\n a = a.getTime();\n b = b.getTime();\n const delta = b - a;\n return t => new Date(a + t * delta);\n }\n const keys = Object.keys(b);\n const interpolators = {};\n keys.forEach(key => {\n interpolators[key] = get_interpolator(a[key], b[key]);\n });\n return t => {\n const result = {};\n keys.forEach(key => {\n result[key] = interpolators[key](t);\n });\n return result;\n };\n }\n if (type === 'number') {\n const delta = b - a;\n return t => a + t * delta;\n }\n throw new Error(`Cannot interpolate ${type} values`);\n}\nfunction tweened(value, defaults = {}) {\n const store = writable(value);\n let task;\n let target_value = value;\n function set(new_value, opts) {\n if (value == null) {\n store.set(value = new_value);\n return Promise.resolve();\n }\n target_value = new_value;\n let previous_task = task;\n let started = false;\n let { delay = 0, duration = 400, easing = linear, interpolate = get_interpolator } = assign(assign({}, defaults), opts);\n if (duration === 0) {\n if (previous_task) {\n previous_task.abort();\n previous_task = null;\n }\n store.set(value = target_value);\n return Promise.resolve();\n }\n const start = now() + delay;\n let fn;\n task = loop(now => {\n if (now < start)\n return true;\n if (!started) {\n fn = interpolate(value, new_value);\n if (typeof duration === 'function')\n duration = duration(value, new_value);\n started = true;\n }\n if (previous_task) {\n previous_task.abort();\n previous_task = null;\n }\n const elapsed = now - start;\n if (elapsed > duration) {\n store.set(value = new_value);\n return false;\n }\n // @ts-ignore\n store.set(value = fn(easing(elapsed / duration)));\n return true;\n });\n return task.promise;\n }\n return {\n set,\n update: (fn, opts) => set(fn(target_value, value), opts),\n subscribe: store.subscribe\n };\n}\n\nexport { spring, tweened };\n"],
"mappings": ";;;;;;;;;;;;;AAIA,iBAAiB,KAAK;AAClB,SAAO,OAAO,UAAU,SAAS,KAAK,GAAG,MAAM;AACnD;AAEA,qBAAqB,KAAK,YAAY,eAAe,cAAc;AAC/D,MAAI,OAAO,kBAAkB,YAAY,QAAQ,aAAa,GAAG;AAE7D,UAAM,QAAQ,eAAe;AAE7B,UAAM,WAAY,iBAAgB,cAAe,KAAI,MAAM,IAAI;AAC/D,UAAM,UAAS,IAAI,KAAK,YAAY;AACpC,UAAM,SAAS,IAAI,KAAK,UAAU;AAClC,UAAM,eAAgB,WAAS,UAAU,IAAI;AAC7C,UAAM,IAAK,YAAW,gBAAgB,IAAI;AAC1C,QAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,aAAa,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,WAAW;AAC1E,aAAO;AAAA,IACX,OACK;AACD,UAAI,UAAU;AAEd,aAAO,QAAQ,aAAa,IACxB,IAAI,KAAK,cAAc,QAAQ,IAAI,CAAC,IAAI,gBAAgB;AAA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