Skip to content

Commit

Permalink
deprecate legacyTranslate and gpuAcceleration (#176)
Browse files Browse the repository at this point in the history
* Push

* Add changeset
  • Loading branch information
PuruVJ authored Dec 6, 2024
1 parent bf2946e commit 0cead87
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 36 deletions.
10 changes: 10 additions & 0 deletions .changeset/seven-schools-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@neodrag/core": minor
"@neodrag/react": minor
"@neodrag/solid": minor
"@neodrag/svelte": minor
"@neodrag/vanilla": minor
"@neodrag/vue": minor
---

deprecate: legacyTranslate and gpuAcceleration
9 changes: 6 additions & 3 deletions docs/src/components/options/Options.astro
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ const orderedOptionsMD = ORDER.map(
<section class='options-examples container'>
{
orderedOptionsMD.map(
({ Content, frontmatter: { defaultValue, title, type } }) => (
({
Content,
frontmatter: { defaultValue, title, type, deprecated, deprecatedText },
}) => (
<>
<h3 id={slugify(title)}>
{title}
Expand All @@ -82,15 +85,15 @@ const orderedOptionsMD = ORDER.map(
href={`#${slugify(title)}`}
>
<PhLinkThin
{
/* @ts-ignore */ }
style='color: var(--app-color-dark)'
width='1em'
height='1em'
/>
</a>
</h3>
<p>
{deprecated === true ? `⚠️ Deprecated: ${deprecatedText}` : ''}
<br />
Type:
<span class='code-like' style='font-family: var(--app-font-mono)'>
{type}
Expand Down
26 changes: 13 additions & 13 deletions docs/src/data/sizes.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"react": {
"size": "2.20",
"version": "2.0.4"
},
"svelte": {
"size": "1.97",
"version": "2.0.6"
"version": "2.1.0"
},
"solid": {
"size": "1.99",
"version": "2.0.4"
"react": {
"size": "2.21",
"version": "2.1.0"
},
"vanilla": {
"size": "2.00",
"version": "2.1.0"
},
"vue": {
"size": "1.99",
"version": "2.0.4"
"size": "2.00",
"version": "2.1.0"
},
"vanilla": {
"size": "2.01",
"version": "2.0.5"
"solid": {
"size": "2.00",
"version": "2.1.0"
}
}
2 changes: 2 additions & 0 deletions docs/src/documentation/options/gpuAcceleration/+option.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: 'gpuAcceleration'
type: 'boolean'
defaultValue: 'true'
deprecated: true
deprecatedText: 'Will be removed in v3'
---

import Code from '$components/options/OptionsCode.astro';
Expand Down
2 changes: 2 additions & 0 deletions docs/src/documentation/options/legacyTranslate/+option.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: legacyTranslate
type: 'boolean'
defaultValue: 'true'
deprecated: true
deprecatedText: 'Will be removed in v3'
---

import Code from '$components/options/OptionsCode.astro';
Expand Down
12 changes: 6 additions & 6 deletions docs/src/layouts/DocsLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ const { title: frontmatterTitle } = frontmatter || {};

<Layout title={title ?? frontmatterTitle}>
<ToC client:only />
<div class="mobile-nav">
<MobileNav client:media="(max-width: 968px)" />
<div class='mobile-nav'>
<MobileNav client:media='(max-width: 968px)' />
</div>

<section class="docs-container" id="docs-container">
<section class='docs-container' id='docs-container'>
<aside>
<Nav client:media="(min-width: 969px)" client:load />
<Nav client:media='(min-width: 969px)' client:load />
</aside>

<main>
Expand All @@ -38,7 +38,7 @@ const { title: frontmatterTitle } = frontmatter || {};
</section>
</Layout>

<style lang="scss">
<style lang='scss'>
@import '../css/breakpoints';

.mobile-nav {
Expand Down Expand Up @@ -146,7 +146,7 @@ const { title: frontmatterTitle } = frontmatter || {};
}
</style>

<style lang="scss" is:global>
<style lang='scss' is:global>
@import '../css/breakpoints';

:root {
Expand Down
12 changes: 6 additions & 6 deletions docs/src/layouts/MainDocsLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ const { size, version } = SIZES[framework];
>
</h1>

<div class="tags">
<span class="tag">
<div class='tags'>
<span class='tag'>
{version}
</span>

<span class="tag">
<span class='tag'>
{size}KB
</span>
</div>
Expand All @@ -42,14 +42,14 @@ const { size, version } = SIZES[framework];
<h2>Credits</h2>
<p>
Inspired from the amazing
<a href="https://github.com/react-grid-layout/react-draggable">
<a href='https://github.com/react-grid-layout/react-draggable'>
react-draggable
</a>
library, and implements the same API.
library, and implements the same API.
</p>
</DocsLayout>

<style lang="scss">
<style lang='scss'>
.tags {
display: flex;
flex-wrap: wrap;
Expand Down
13 changes: 5 additions & 8 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export type DragOptions = {
*
* At present this is true by default, but will be changed to false in a future major version.
*
* @default true
* @default false
* @deprecated Use `transform` option instead for transform: translate() or any other custom transform. Will be removed in v3.
*/
legacyTranslate?: boolean;

Expand All @@ -92,6 +93,7 @@ export type DragOptions = {
* `true` by default, but can be set to `false` if [blurry text issue](https://developpaper.com/question/why-does-the-use-of-css3-translate3d-result-in-blurred-display/) occur
*
* @default true
* @deprecated Use `transform` option instead with translate(x, y, 1px). 1px forces some browsers to use GPU acceleration. Will be removed in v3
*/
gpuAcceleration?: boolean;

Expand Down Expand Up @@ -272,7 +274,7 @@ export function draggable(node: HTMLElement, options: DragOptions = {}) {
bounds,
axis = 'both',
gpuAcceleration = true,
legacyTranslate = true,
legacyTranslate = false,
transform,
applyUserSelectHack = true,
disabled = false,
Expand Down Expand Up @@ -335,7 +337,6 @@ export function draggable(node: HTMLElement, options: DragOptions = {}) {
// Set proper defaults for recomputeBounds
recomputeBounds = { ...DEFAULT_RECOMPUTE_BOUNDS, ...recomputeBounds };

console.log(threshold);
// Proper defaults for threshold
threshold = { ...DEFAULT_DRAG_THRESHOLD, ...(threshold ?? {}) };

Expand Down Expand Up @@ -382,11 +383,7 @@ export function draggable(node: HTMLElement, options: DragOptions = {}) {
);
}

return set_style(
node,
'translate',
`${+x_pos}px ${+y_pos}px ${gpuAcceleration ? '1px' : ''}`,
);
return set_style(node, 'translate', `${+x_pos}px ${+y_pos}px`);
}

// Call transform function if provided
Expand Down

0 comments on commit 0cead87

Please sign in to comment.