Skip to content

Commit ddcde4b

Browse files
Merge pull request #5 from node-projects/feature/slidershow
Feature/slidershow
2 parents 63d4d95 + d517bb4 commit ddcde4b

File tree

6 files changed

+21
-23
lines changed

6 files changed

+21
-23
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@node-projects/automatic-slidershow-webcomponent",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "",
55
"type": "module",
66
"private": false,
@@ -32,4 +32,4 @@
3232
"dependencies": {
3333
"@node-projects/base-custom-webcomponent": "^0.17.2"
3434
}
35-
}
35+
}

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: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class AutomaticSliderShowWebcomponent extends BaseCustomWebComponentConst
2323
2424
.slideshow-container{
2525
grid-area: 1 / 1 / 2 / 2;
26-
width: calc(100% - 20px);
26+
width: 100%;
2727
height: 100%;
2828
border: 1px solid grey;
2929
overflow: hidden;
@@ -109,7 +109,7 @@ export class AutomaticSliderShowWebcomponent extends BaseCustomWebComponentConst
109109

110110
connectedCallback() {
111111
this._observer.observe(this, { childList: true });
112-
this._interval = parseInt(this.getAttribute('interval'));
112+
this._interval = parseInt(this.getAttribute('interval')) || this._interval;
113113
this._initializeSlider();
114114
}
115115

@@ -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)