From 4dd0fa87859e6ffa1b230eedd1388098a8ba81a1 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Thu, 17 Oct 2024 12:40:50 +0800 Subject: feat: set "sticky" as one of default layouts * move function addDraggable() into module scope * showcase in sticky layout is draggable now * add query paramerter for "use" * FIX: set initialLayout after observer is set --- addon/index.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addon') diff --git a/addon/index.mjs b/addon/index.mjs index b5d71ba..77716b6 100644 --- a/addon/index.mjs +++ b/addon/index.mjs @@ -1,4 +1,5 @@ const url = new URL(window.location) +const use = url.searchParams.get('use') if (url.host === 'www.ptt.cc') { const content = document.querySelector('#main-content') Array.from(content.childNodes) @@ -22,7 +23,7 @@ const addBlocks = blockSelector : undefined const simpleRender = window.mapclay.renderWith(config => ({ - use: 'Leaflet', + use: use ?? 'Leaflet', width: '100%', height: '200px', XYZ: 'https://tile.openstreetmap.jp/styles/osm-bright/512/{z}/{x}/{y}.png', @@ -36,7 +37,7 @@ const simpleRender = window.mapclay.renderWith(config => ({ window.generateMaps(document.querySelector('main') ?? document.body, { crs: url.searchParams.get('crs') ?? 'EPSG:4326', addBlocks, - initialLayout: '', + initialLayout: 'sticky', render: simpleRender, autoMap: true, }) -- cgit v1.2.3-70-g09d2