Skip to content

Commit d517bb4

Browse files
author
Cedric Franke
committed
Build features to use component in web-component-designer #4 -> fix dot placment in designer
1 parent 106a2e6 commit d517bb4

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

src/designer/ElementInteractionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IDesignerCanvas, IElementInteractionService } from "@node-projects/web-component-designer";
2-
import { AutomaticSliderShowWebcomponent } from "../slider/AutomaticSliderShowWebcomponent";
2+
import { AutomaticSliderShowWebcomponent } from "../slider/AutomaticSliderShowWebcomponent.js";
33

44
export default class ElementInteractionService implements IElementInteractionService {
55
stopEventHandling(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element) {

src/designer/TabPlacementService.ts renamed to src/designer/SliderShowPlacementService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DefaultPlacementService, IDesignItem, IPlacementView, IPoint } from "@node-projects/web-component-designer";
2-
import { AutomaticSliderShowWebcomponent } from "../slider/AutomaticSliderShowWebcomponent";
2+
import { AutomaticSliderShowWebcomponent } from "../slider/AutomaticSliderShowWebcomponent.js";
33

44
export default class SliderShowPlacementService extends DefaultPlacementService {
55
override serviceForContainer(container: IDesignItem, containerStyle: CSSStyleDeclaration) {

src/slider/AutomaticSliderShowWebcomponent.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,6 @@ export class AutomaticSliderShowWebcomponent extends BaseCustomWebComponentConst
121121

122122
ready() {
123123
this._parseAttributesToProperties();
124-
let count = 1;
125-
for (let index = 0; index < this.children.length; index++) {
126-
const dotElement = document.createElement('div');
127-
dotElement.className = "dot-element";
128-
dotElement.id = "dot-element-" + count;
129-
this._dots.appendChild(dotElement);
130-
count++;
131-
}
132-
133-
(<HTMLDivElement>this._dots.children[0]).classList.add("dot-active");
134-
135124
(<HTMLDivElement>this._getDomElement('left-arrow')).onclick = () => this.prevSlide();
136125
(<HTMLDivElement>this._getDomElement('right-arrow')).onclick = () => this.nextSlide();
137126
}
@@ -151,6 +140,18 @@ export class AutomaticSliderShowWebcomponent extends BaseCustomWebComponentConst
151140
this._slideIndex = 0;
152141
}
153142

143+
let count = 1;
144+
this._dots.innerHTML = "";
145+
for (let index = 0; index < this.children.length; index++) {
146+
const dotElement = document.createElement('div');
147+
dotElement.className = "dot-element";
148+
dotElement.id = "dot-element-" + count;
149+
this._dots.appendChild(dotElement);
150+
count++;
151+
}
152+
153+
(<HTMLDivElement>this._dots.children[this._slideIndex]).classList.add("dot-active");
154+
154155
let i = 0;
155156
for (const item of this.children as any as HTMLElement[]) {
156157
item.setAttribute('slot', i === this._slideIndex ? 'main' : '');

web-component-designer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
"./dist/designer/ElementInteractionService.js"
66
],
77
"containerService": [
8-
"./dist/designer/TabPlacementService.js"
9-
],
10-
"attachedPropertyService": [
11-
"./dist/designer/AttachedPropertiesService.js"
8+
"./dist/designer/SliderShowPlacementService.js"
129
]
1310
}
1411
}

0 commit comments

Comments
 (0)