Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<a name="1.0.0-rc.11"></a>
# [1.0.0-rc.11](https://github.com/deckgo/deckdeckgo/compare/v1.0.0-rc.10...v1.0.0-11) (2019-09-01)

### Web Components
* inline-editor: v1.0.0-rc.1-1 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/master/webcomponents/inline-editor/CHANGELOG.md))

### Others
* utils: v1.0.0-rc.1-1 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/master/webcomponents/utils/CHANGELOG.md))

<a name="1.0.0-rc.10"></a>
# [1.0.0-rc.10](https://github.com/deckgo/deckdeckgo/compare/v1.0.0-rc.9...v1.0.0-10) (2019-08-30)

Expand Down
14 changes: 7 additions & 7 deletions studio/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@deckdeckgo/core": "^1.0.0-rc.1",
"@deckdeckgo/highlight-code": "^1.0.0-rc.1",
"@deckdeckgo/inline-editor": "^1.0.0-rc.1",
"@deckdeckgo/inline-editor": "^1.0.0-rc.1-1",
"@deckdeckgo/lazy-img": "^1.0.0-rc.1",
"@deckdeckgo/qrcode": "^1.0.0-rc.1",
"@deckdeckgo/remote": "^1.0.0-rc.1",
Expand All @@ -26,7 +26,7 @@
"@deckdeckgo/slide-split": "^1.0.0-rc.1",
"@deckdeckgo/slide-title": "^1.0.0-rc.1",
"@deckdeckgo/slide-youtube": "^1.0.0-rc.1",
"@deckdeckgo/utils": "^1.0.0-rc.1",
"@deckdeckgo/utils": "^1.0.0-rc.1-1",
"@ionic/core": "^4.8.1",
"firebase": "^6.3.5",
"idb-keyval": "^3.2.0",
Expand Down
7 changes: 7 additions & 0 deletions webcomponents/inline-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<a name="1.0.0-rc.1-1"></a>
# 1.0.0-rc.1-1 (2019-09-01)

### Fix

* debounce the display of the toolbar (useful in case of dragged selection)

<a name="1.0.0-rc.1"></a>
# 1.0.0-rc.1 (2019-08-30)

Expand Down
8 changes: 4 additions & 4 deletions webcomponents/inline-editor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webcomponents/inline-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deckdeckgo/inline-editor",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.1-1",
"description": "A WYSIWYG HTML Inline Editor Web Component",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -22,7 +22,7 @@
"test.watch": "stencil test --spec --e2e --watchAll"
},
"dependencies": {
"@deckdeckgo/utils": "^1.0.0-rc.1"
"@deckdeckgo/utils": "^1.0.0-rc.1-1"
},
"devDependencies": {
"@stencil/core": "^1.3.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
div.deckgo-tools {
position: absolute;
visibility: hidden;
opacity: 0;

animation: 0s ease 0s 1 normal none running none;

pointer-events: none;

Expand Down Expand Up @@ -135,9 +138,8 @@ div.deckgo-tools {
}

&.deckgo-tools-activated {
transition: top 75ms ease-out, left 75ms ease-out;
animation: pop-upwards 180ms forwards linear;
visibility: visible;
opacity: 1;
}

&.deckgo-tools-mobile {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, Element, EventEmitter, Listen, Prop, State, Watch, Event, Method, h} from '@stencil/core';

import {isMobile, isIOS, unifyEvent} from '@deckdeckgo/utils';
import {isMobile, isIOS, unifyEvent, debounce} from '@deckdeckgo/utils';

import {DeckdeckgoInlineEditorUtils} from '../../types/inline-editor/deckdeckgo-inline-editor-utils';

Expand Down Expand Up @@ -79,6 +79,11 @@ export class DeckdeckgoInlineEditor {
@State()
private toolsActivated: boolean = false;

@State()
private displayToolsActivated: boolean = false;

private debounceDisplayToolsActivated: Function;

private selection: Selection = null;

private anchorLink: AnchorLink = null;
Expand Down Expand Up @@ -121,6 +126,16 @@ export class DeckdeckgoInlineEditor {
@Prop()
list: boolean = true;

constructor() {
this.resetDisplayToolsActivated();
}

private resetDisplayToolsActivated() {
this.debounceDisplayToolsActivated = debounce(() => {
this.displayToolsActivated = true;
});
}

async componentWillLoad() {
await this.attachListener();
}
Expand Down Expand Up @@ -153,8 +168,8 @@ export class DeckdeckgoInlineEditor {
return new Promise<void>((resolve) => {
const listenerElement: HTMLElement | Document = this.attachTo ? this.attachTo : document;
if (listenerElement) {
listenerElement.addEventListener('mousedown', this.mousedown, {passive: true});
listenerElement.addEventListener('touchstart', this.touchstart, {passive: true});
listenerElement.addEventListener('mousedown', this.startSelection, {passive: true});
listenerElement.addEventListener('touchstart', this.startSelection, {passive: true});
}

resolve();
Expand All @@ -164,34 +179,28 @@ export class DeckdeckgoInlineEditor {
private detachListener(listenerElement: HTMLElement | Document): Promise<void> {
return new Promise<void>((resolve) => {
if (listenerElement) {
listenerElement.removeEventListener('mousedown', this.mousedown);
listenerElement.removeEventListener('touchstart', this.touchstart);
listenerElement.removeEventListener('mousedown', this.startSelection);
listenerElement.removeEventListener('touchstart', this.startSelection);
}

resolve();
});
}

private mousedown = async ($event: MouseEvent) => {
if (this.toolsActivated) {
await this.resetImageToolbarActions($event);

return;
private startSelection = async ($event: MouseEvent | TouchEvent) => {
if (this.toolbarActions !== ToolbarActions.IMAGE) {
this.anchorEvent = $event;
}

this.anchorEvent = $event;

await this.displayImageActions($event);
};

private touchstart = async ($event: TouchEvent) => {
if (this.toolsActivated) {
await this.resetImageToolbarActions($event);

return;
}

this.anchorEvent = $event;
if (this.toolbarActions === ToolbarActions.IMAGE) {
this.anchorEvent = $event;
}

await this.displayImageActions($event);
};
Expand Down Expand Up @@ -411,7 +420,7 @@ export class DeckdeckgoInlineEditor {
return;
}

if(this.iOSTimerScroll > 0) {
if (this.iOSTimerScroll > 0) {
clearTimeout(this.iOSTimerScroll);
}

Expand Down Expand Up @@ -610,6 +619,8 @@ export class DeckdeckgoInlineEditor {

await this.setToolsActivated(false);

this.resetDisplayToolsActivated();

this.selection = null;

this.toolbarActions = ToolbarActions.SELECTION;
Expand Down Expand Up @@ -858,6 +869,12 @@ export class DeckdeckgoInlineEditor {
return new Promise<void>(async (resolve) => {
this.toolsActivated = activated;

if (activated) {
this.debounceDisplayToolsActivated();
} else {
this.displayToolsActivated = false;
}

if (this.isSticky()) {
this.stickyToolbarActivated.emit(this.toolsActivated);
}
Expand Down Expand Up @@ -1020,7 +1037,7 @@ export class DeckdeckgoInlineEditor {
}

render() {
let classNames: string = this.toolsActivated ? (this.mobile ? 'deckgo-tools deckgo-tools-activated deckgo-tools-mobile' : 'deckgo-tools deckgo-tools-activated') : (this.mobile ? 'deckgo-tools deckgo-tools-mobile' : 'deckgo-tools');
let classNames: string = this.displayToolsActivated ? (this.mobile ? 'deckgo-tools deckgo-tools-activated deckgo-tools-mobile' : 'deckgo-tools deckgo-tools-activated') : (this.mobile ? 'deckgo-tools deckgo-tools-mobile' : 'deckgo-tools');

if (this.isSticky()) {
classNames += ' deckgo-tools-sticky';
Expand Down
5 changes: 5 additions & 0 deletions webcomponents/utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a name="1.0.0-rc.1-1"></a>
# 1.0.0-rc.1-1 (2019-09-01)

* improvate `debounce` typing

<a name="1.0.0-rc.1"></a>
# 1.0.0-rc.1 (2019-08-30)

Expand Down
2 changes: 1 addition & 1 deletion webcomponents/utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webcomponents/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deckdeckgo/utils",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.1-1",
"author": "David Dal Busco",
"description": "A collection of utils methods and functions developed for DeckDeckGo",
"license": "MIT",
Expand Down
10 changes: 6 additions & 4 deletions webcomponents/utils/src/utils/deckdeckgo-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ export function unifyEvent(e: any): any {
}

export function debounce(func: Function, timeout?: number) {
let timer: number;
return ($args: any) => {
let timer: number | undefined;

return (...args: any[]) => {
const next = () => func(...args);

if (timer) {
clearTimeout(timer);
}

// @ts-ignore
timer = setTimeout(func, timeout > 0 ? timeout : 300, $args);
timer = setTimeout(next, timeout && timeout > 0 ? timeout : 300);
};
}

Expand Down