diff --git a/src/index-lite.js b/src/index-lite.js index 10c000c..bd47e9e 100644 --- a/src/index-lite.js +++ b/src/index-lite.js @@ -12,18 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - ScrollTimeline, - ViewTimeline, -} from "./scroll-timeline-base"; -import { - animate, - elementGetAnimations, - documentGetAnimations, - ProxyAnimation -} from "./proxy-animation.js"; - - import { initPolyfill } from "./init-polyfill.js" initPolyfill(); diff --git a/src/init-polyfill.js b/src/init-polyfill.js index 1136770..e3dd471 100644 --- a/src/init-polyfill.js +++ b/src/init-polyfill.js @@ -27,7 +27,7 @@ import { initCSSPolyfill } from "./scroll-timeline-css" export function initPolyfill() { // Don't load if browser claims support - if (CSS.supports("view-timeline")) { + if (window.ViewTimeline !== undefined) { return true; } diff --git a/src/scroll-timeline-css.js b/src/scroll-timeline-css.js index c38bb38..5d3d0b0 100644 --- a/src/scroll-timeline-css.js +++ b/src/scroll-timeline-css.js @@ -154,7 +154,7 @@ function updateKeyframesIfNecessary(anim, options) { export function initCSSPolyfill() { // Don't load if browser claims support - if (CSS.supports("view-timeline")) { + if (CSS.supports("animation-timeline: --works")) { return true; } diff --git a/vite.config.common.js b/vite.config.common.js new file mode 100644 index 0000000..eb842fc --- /dev/null +++ b/vite.config.common.js @@ -0,0 +1,28 @@ +export function buildConfig(source, filename) { + return { + build: { + sourcemap: true, + emptyOutDir: false, + lib: { + // Could also be a dictionary or array of multiple entry points + entry: source, + name: 'ScrollTimeline', + // the proper extensions will be added + fileName: (format, entryAlias) => `${filename}${format=='iife'?'':'-' + format}.js`, + formats: ['iife'], + }, + minify: 'terser', + terserOptions: { + keep_classnames: /^((View|Scroll)Timeline)|CSS.*$/ + }, + rollupOptions: { + output: { + // Provide global variables to use in the UMD build + // for externalized deps + globals: { + }, + }, + } + } + }; +} \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 6a27226..b6c8644 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,28 +1,5 @@ import { resolve } from 'path' import { defineConfig } from 'vite' +import { buildConfig } from './vite.config.common' -export default defineConfig({ - build: { - sourcemap: true, - lib: { - // Could also be a dictionary or array of multiple entry points - entry: resolve(__dirname, 'src/index.js'), - name: 'ScrollTimeline', - // the proper extensions will be added - fileName: (format, entryAlias) => `scroll-timeline${format=='iife'?'':'-' + format}.js`, - formats: ['iife'], - }, - minify: 'terser', - terserOptions: { - keep_classnames: /^((View|Scroll)Timeline)|CSS.*$/ - }, - rollupOptions: { - output: { - // Provide global variables to use in the UMD build - // for externalized deps - globals: { - }, - }, - } - }, -}) +export default defineConfig(buildConfig(resolve(__dirname, 'src/index.js'), 'scroll-timeline')); \ No newline at end of file diff --git a/vite.config.lite.js b/vite.config.lite.js index e41e541..31f5e11 100644 --- a/vite.config.lite.js +++ b/vite.config.lite.js @@ -1,29 +1,5 @@ import { resolve } from 'path' import { defineConfig } from 'vite' +import { buildConfig } from './vite.config.common' -export default defineConfig({ - build: { - sourcemap: true, - outDir: 'dist-lite', - lib: { - // Could also be a dictionary or array of multiple entry points - entry: resolve(__dirname, 'src/index-lite.js'), - name: 'ScrollTimelineLite', - // the proper extensions will be added - fileName: (format, entryAlias) => `scroll-timeline-lite${format=='iife'?'':'-' + format}.js`, - formats: ['iife'], - }, - minify: 'terser', - terserOptions: { - keep_classnames: /^((View|Scroll)Timeline)|CSS.*$/ - }, - rollupOptions: { - output: { - // Provide global variables to use in the UMD build - // for externalized deps - globals: { - }, - }, - } - }, -}) +export default defineConfig(buildConfig(resolve(__dirname, 'src/index-lite.js'), 'scroll-timeline-lite')); \ No newline at end of file