Skip to content

Commit

Permalink
@sidy/core - fix default options
Browse files Browse the repository at this point in the history
  • Loading branch information
Valexr committed Sep 18, 2022
1 parent 19c9c0a commit 9b2fb4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/lib/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function dom(node: HTMLElement, options: Options): Dom {

function pos(index: number, snap?: Options['snap']): number {
const indented = child(index)[size] + gap * 2 < node[size];
const indent = indented ? (options.indent || 0) : offset(index) / 2 / gap;
const indent = indented ? (options.indent ?? 1) : offset(index) / 2 / gap;
const part = snap === 'start' ? 0 : snap === 'end' ? 1 : 0.5;
const edge = snap === 'start' ? -indent : snap === 'end' ? indent : 0;
return child(index)[coord] - offset(index) * part + gap * edge;
Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/slidy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export function slidy(node: HTMLElement, options: Partial<Options> = {}): SlidyI
track = 0,
clamped: number | boolean,
wst: NodeJS.Timeout | undefined,
INDEX = hix = options.index ||= 0,
POSITION = options.position ||= 0,
DIRECTION = options.direction ||= 0,
DURATION = (options.duration ||= 450) / 2,
SENSITY = options.sensity ||= 2.5,
GRAVITY = options.gravity ||= 1.2,
CLAMP = options.clamp;
INDEX = hix = options.index ??= 0,
POSITION = options.position ??= 0,
DIRECTION = options.direction ??= 0,
DURATION = (options.duration ??= 450) / 2,
SENSITY = options.sensity ??= 2.5,
GRAVITY = options.gravity ??= 1.2,
CLAMP = options.clamp ??= 0;

const WINDOW_EVENTS: EventMap = [
['touchmove', onMove as EventListener, { passive: false }],
Expand All @@ -44,8 +44,8 @@ export function slidy(node: HTMLElement, options: Partial<Options> = {}): SlidyI
];

const RO = new ResizeObserver((ROE) => {
to(INDEX);
POSITION = options.position = $().position();
to(INDEX);
dispatch(node, 'resize', { ROE, options });
});

Expand All @@ -65,12 +65,12 @@ export function slidy(node: HTMLElement, options: Partial<Options> = {}): SlidyI

const instance = { init, update, destroy, to }

init();

loop(options.plugins || [], (plugin, i, array) => {
array[i] = plugin({ node, options, instance })
})

init();

function init() {
mount(node).then(() => {

Expand Down

0 comments on commit 9b2fb4c

Please sign in to comment.