Skip to content

Commit 0cead87

Browse files
authored
deprecate legacyTranslate and gpuAcceleration (#176)
* Push * Add changeset
1 parent bf2946e commit 0cead87

File tree

8 files changed

+50
-36
lines changed

8 files changed

+50
-36
lines changed

.changeset/seven-schools-relax.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@neodrag/core": minor
3+
"@neodrag/react": minor
4+
"@neodrag/solid": minor
5+
"@neodrag/svelte": minor
6+
"@neodrag/vanilla": minor
7+
"@neodrag/vue": minor
8+
---
9+
10+
deprecate: legacyTranslate and gpuAcceleration

docs/src/components/options/Options.astro

+6-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ const orderedOptionsMD = ORDER.map(
7070
<section class='options-examples container'>
7171
{
7272
orderedOptionsMD.map(
73-
({ Content, frontmatter: { defaultValue, title, type } }) => (
73+
({
74+
Content,
75+
frontmatter: { defaultValue, title, type, deprecated, deprecatedText },
76+
}) => (
7477
<>
7578
<h3 id={slugify(title)}>
7679
{title}
@@ -82,15 +85,15 @@ const orderedOptionsMD = ORDER.map(
8285
href={`#${slugify(title)}`}
8386
>
8487
<PhLinkThin
85-
{
86-
/* @ts-ignore */ }
8788
style='color: var(--app-color-dark)'
8889
width='1em'
8990
height='1em'
9091
/>
9192
</a>
9293
</h3>
9394
<p>
95+
{deprecated === true ? `⚠️ Deprecated: ${deprecatedText}` : ''}
96+
<br />
9497
Type:
9598
<span class='code-like' style='font-family: var(--app-font-mono)'>
9699
{type}

docs/src/data/sizes.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
2-
"react": {
3-
"size": "2.20",
4-
"version": "2.0.4"
5-
},
62
"svelte": {
73
"size": "1.97",
8-
"version": "2.0.6"
4+
"version": "2.1.0"
95
},
10-
"solid": {
11-
"size": "1.99",
12-
"version": "2.0.4"
6+
"react": {
7+
"size": "2.21",
8+
"version": "2.1.0"
9+
},
10+
"vanilla": {
11+
"size": "2.00",
12+
"version": "2.1.0"
1313
},
1414
"vue": {
15-
"size": "1.99",
16-
"version": "2.0.4"
15+
"size": "2.00",
16+
"version": "2.1.0"
1717
},
18-
"vanilla": {
19-
"size": "2.01",
20-
"version": "2.0.5"
18+
"solid": {
19+
"size": "2.00",
20+
"version": "2.1.0"
2121
}
2222
}

docs/src/documentation/options/gpuAcceleration/+option.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: 'gpuAcceleration'
33
type: 'boolean'
44
defaultValue: 'true'
5+
deprecated: true
6+
deprecatedText: 'Will be removed in v3'
57
---
68

79
import Code from '$components/options/OptionsCode.astro';

docs/src/documentation/options/legacyTranslate/+option.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: legacyTranslate
33
type: 'boolean'
44
defaultValue: 'true'
5+
deprecated: true
6+
deprecatedText: 'Will be removed in v3'
57
---
68

79
import Code from '$components/options/OptionsCode.astro';

docs/src/layouts/DocsLayout.astro

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ const { title: frontmatterTitle } = frontmatter || {};
2121

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

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

3333
<main>
@@ -38,7 +38,7 @@ const { title: frontmatterTitle } = frontmatter || {};
3838
</section>
3939
</Layout>
4040

41-
<style lang="scss">
41+
<style lang='scss'>
4242
@import '../css/breakpoints';
4343

4444
.mobile-nav {
@@ -146,7 +146,7 @@ const { title: frontmatterTitle } = frontmatter || {};
146146
}
147147
</style>
148148

149-
<style lang="scss" is:global>
149+
<style lang='scss' is:global>
150150
@import '../css/breakpoints';
151151

152152
:root {

docs/src/layouts/MainDocsLayout.astro

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ const { size, version } = SIZES[framework];
2525
>
2626
</h1>
2727

28-
<div class="tags">
29-
<span class="tag">
28+
<div class='tags'>
29+
<span class='tag'>
3030
{version}
3131
</span>
3232

33-
<span class="tag">
33+
<span class='tag'>
3434
{size}KB
3535
</span>
3636
</div>
@@ -42,14 +42,14 @@ const { size, version } = SIZES[framework];
4242
<h2>Credits</h2>
4343
<p>
4444
Inspired from the amazing
45-
<a href="https://github.com/react-grid-layout/react-draggable">
45+
<a href='https://github.com/react-grid-layout/react-draggable'>
4646
react-draggable
4747
</a>
48-
library, and implements the same API.
48+
library, and implements the same API.
4949
</p>
5050
</DocsLayout>
5151

52-
<style lang="scss">
52+
<style lang='scss'>
5353
.tags {
5454
display: flex;
5555
flex-wrap: wrap;

packages/core/src/index.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export type DragOptions = {
8282
*
8383
* At present this is true by default, but will be changed to false in a future major version.
8484
*
85-
* @default true
85+
* @default false
86+
* @deprecated Use `transform` option instead for transform: translate() or any other custom transform. Will be removed in v3.
8687
*/
8788
legacyTranslate?: boolean;
8889

@@ -92,6 +93,7 @@ export type DragOptions = {
9293
* `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
9394
*
9495
* @default true
96+
* @deprecated Use `transform` option instead with translate(x, y, 1px). 1px forces some browsers to use GPU acceleration. Will be removed in v3
9597
*/
9698
gpuAcceleration?: boolean;
9799

@@ -272,7 +274,7 @@ export function draggable(node: HTMLElement, options: DragOptions = {}) {
272274
bounds,
273275
axis = 'both',
274276
gpuAcceleration = true,
275-
legacyTranslate = true,
277+
legacyTranslate = false,
276278
transform,
277279
applyUserSelectHack = true,
278280
disabled = false,
@@ -335,7 +337,6 @@ export function draggable(node: HTMLElement, options: DragOptions = {}) {
335337
// Set proper defaults for recomputeBounds
336338
recomputeBounds = { ...DEFAULT_RECOMPUTE_BOUNDS, ...recomputeBounds };
337339

338-
console.log(threshold);
339340
// Proper defaults for threshold
340341
threshold = { ...DEFAULT_DRAG_THRESHOLD, ...(threshold ?? {}) };
341342

@@ -382,11 +383,7 @@ export function draggable(node: HTMLElement, options: DragOptions = {}) {
382383
);
383384
}
384385

385-
return set_style(
386-
node,
387-
'translate',
388-
`${+x_pos}px ${+y_pos}px ${gpuAcceleration ? '1px' : ''}`,
389-
);
386+
return set_style(node, 'translate', `${+x_pos}px ${+y_pos}px`);
390387
}
391388

392389
// Call transform function if provided

0 commit comments

Comments
 (0)