├── .gitignore ├── .travis.yml ├── src ├── constants.js ├── utils.js ├── Divider.html ├── Pane.html ├── elements.js └── Subdivide.html ├── test ├── public │ └── index.html ├── runner.js └── src │ └── index.js ├── appveyor.yml ├── rollup.config.js ├── CHANGELOG.md ├── LICENSE ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | yarn.lock 4 | yarn-error.log 5 | package-lock.json 6 | index.mjs 7 | index.js 8 | test/public/bundle.js 9 | !test/src/index.js -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "stable" 4 | 5 | env: 6 | global: 7 | - BUILD_TIMEOUT=10000 8 | 9 | before_install: 10 | - sudo apt-get update 11 | - sudo apt-get install -y xsel -------------------------------------------------------------------------------- /src/constants.js: -------------------------------------------------------------------------------- 1 | export const NORTH = 'NORTH'; 2 | export const SOUTH = 'SOUTH'; 3 | export const EAST = 'EAST'; 4 | export const WEST = 'WEST'; 5 | 6 | export const IS_MAC = navigator.platform === 'MacIntel'; 7 | export const KEYCODE = IS_MAC ? 91 : 17; // Cmd : Ctrl -------------------------------------------------------------------------------- /test/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
svelte-virtual-list tests 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/utils.js: -------------------------------------------------------------------------------- 1 | export function clamp(num, min, max) { 2 | if (num < min) return min; 3 | if (num > max) return max; 4 | return num; 5 | } 6 | 7 | export function removeFromArray(array, item) { 8 | const index = array.indexOf(item); 9 | if (index === -1) throw new Error('Unexpected error'); 10 | array.splice(index, 1); 11 | } 12 | 13 | export function getId() { 14 | return Math.random().toString(36).slice(2); 15 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # http://www.appveyor.com/docs/appveyor-yml 2 | 3 | version: "{build}" 4 | 5 | clone_depth: 10 6 | 7 | init: 8 | - git config --global core.autocrlf false 9 | 10 | environment: 11 | matrix: 12 | # node.js 13 | - nodejs_version: 8 14 | 15 | install: 16 | - ps: Install-Product node $env:nodejs_version 17 | - npm install 18 | 19 | build: off 20 | 21 | test_script: 22 | - node --version && npm --version 23 | - npm test 24 | 25 | matrix: 26 | fast_finish: false 27 | 28 | # cache: 29 | # - C:\Users\appveyor\AppData\Roaming\npm-cache -> package.json # npm cache 30 | # - node_modules -> package.json # local npm modules -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import svelte from 'rollup-plugin-svelte'; 2 | import resolve from 'rollup-plugin-node-resolve'; 3 | import commonjs from 'rollup-plugin-commonjs'; 4 | import pkg from './package.json'; 5 | 6 | export default [ 7 | { 8 | input: 'src/Subdivide.html', 9 | output: [ 10 | { file: pkg.module, 'format': 'es' }, 11 | { file: pkg.main, 'format': 'umd', name: 'Subdivide' } 12 | ], 13 | plugins: [ 14 | resolve(), 15 | svelte() 16 | ] 17 | }, 18 | 19 | // tests 20 | { 21 | input: 'test/src/index.js', 22 | output: { 23 | file: 'test/public/bundle.js', 24 | format: 'iife' 25 | }, 26 | plugins: [ 27 | resolve(), 28 | commonjs(), 29 | svelte() 30 | ] 31 | } 32 | ]; -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # svelte-subdivide changelog 2 | 3 | ## 2.2.0 4 | 5 | * Fire `open`, `close` and `layout` events ([#20](https://github.com/sveltejs/svelte-subdivide/issues/20)) 6 | * Indicate when pane will be closed via custom cursor 7 | 8 | ## 2.1.0 9 | 10 | * Expose `layout` property for implementing save and restore ([#17](https://github.com/sveltejs/svelte-subdivide/pull/17)) 11 | * Use unique IDs, rather than sequential ones ([#19](https://github.com/sveltejs/svelte-subdivide/pull/19)) 12 | 13 | ## 2.0.0 14 | 15 | * Replace `spacing` parameter with `thickness` and `padding` 16 | * Add visual indicators for dragging and splitting 17 | * Prevent text selection during dragging 18 | * Use ctrl key in non-Mac environments 19 | * Fix broken relationships when dragging twice from left/top edge of a pane 20 | 21 | ## 1.0.0 22 | 23 | * First release -------------------------------------------------------------------------------- /test/runner.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | const ports = require('port-authority'); 3 | const handler = require('serve-handler'); 4 | const puppeteer = require('puppeteer'); 5 | 6 | async function go() { 7 | const port = await ports.find(1234); 8 | console.log(`found available port: ${port}`); 9 | 10 | const server = http.createServer((req, res) => { 11 | handler(req, res, { 12 | public: 'test/public' 13 | }); 14 | }); 15 | 16 | server.listen(port); 17 | 18 | await ports.wait(port).catch(() => {}); // workaround windows gremlins 19 | 20 | const browser = await puppeteer.launch({args: ['--no-sandbox']}); 21 | const page = await browser.newPage(); 22 | 23 | page.on('console', msg => { 24 | console[msg.type()](msg.text()); 25 | }); 26 | 27 | await page.goto(`http://localhost:${port}`); 28 | 29 | await page.evaluate(() => done); 30 | await browser.close(); 31 | server.close(); 32 | } 33 | 34 | go(); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Rich Harris 2 | 3 | Permission is hereby granted by the authors of this software, to any person, to use the software for any purpose, free of charge, including the rights to run, read, copy, change, distribute and sell it, and including usage rights to any patents the authors may hold on it, subject to the following conditions: 4 | 5 | This license, or a link to its text, must be included with all copies of the software and any derivative works. 6 | 7 | Any modification to the software submitted to the authors may be incorporated into the software under the terms of this license. 8 | 9 | The software is provided "as is", without warranty of any kind, including but not limited to the warranties of title, fitness, merchantability and non-infringement. The authors have no obligation to provide support or updates for the software, and may not be held liable for any damages, claims or other liability arising from its use. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@sveltejs/svelte-subdivide", 3 | "version": "2.2.0", 4 | "description": "A