Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/npm-run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
scope: "@webtides"
scope: '@webtides'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
scope: "@webtides"
scope: '@webtides'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand All @@ -42,11 +42,11 @@ jobs:
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
scope: "@webtides"
scope: '@webtides'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

4 changes: 4 additions & 0 deletions packages/interactions/slider-element/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
<!-- ### Removed -->
<!-- ### Fixed -->

## [0.4.16] - 2025-11-25

- fix error in slider-element, cause by missing items check

## [0.4.15] - 2022-07-21

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/interactions/slider-element/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webtides/slider-element",
"version": "0.4.15",
"version": "0.4.16",
"description": "A slider element that lets you slide child elements",
"author": "@webtides",
"homepage": "https://github.com/webtides/element-library",
Expand Down
63 changes: 34 additions & 29 deletions packages/interactions/slider-element/src/slider-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ export default class SliderElement extends TemplateElement {
super({ shadowRender: true, deferUpdate: true, adoptGlobalStyles: false, styles: [style], ...options });
}

properties() {
return {
itemSelector: '.item',
itemsToShow: 1,
itemsToScroll: 1,
rewind: false,
selectedIndex: 0,
autoSelect: false,
dots: true,
arrows: true,
setIndexAfterResize: true,
manualScrollEndDelay: 200,
};
}

get canSlide() {
if (!this.$refs.scroller) {
return false;
Expand All @@ -42,6 +27,21 @@ export default class SliderElement extends TemplateElement {
return this.selectedIndex < this.itemsCount;
}

properties() {
return {
itemSelector: '.item',
itemsToShow: 1,
itemsToScroll: 1,
rewind: false,
selectedIndex: 0,
autoSelect: false,
dots: true,
arrows: true,
setIndexAfterResize: true,
manualScrollEndDelay: 200,
};
}

connected() {
this.indexItems();
this.requestUpdate().then(() => {
Expand Down Expand Up @@ -96,13 +96,15 @@ export default class SliderElement extends TemplateElement {
if (this.autoSelect && this.canSlide) {
//check if element is already visible
const target = this.items[this.selectedIndex];
const parent = this.$refs.scroller;
const { marginLeft, marginRight } = getComputedStyle(target);
const targetWidth = target.offsetWidth + parseInt(marginLeft) + parseInt(marginRight);
if (target.offsetLeft + targetWidth < parent.scrollLeft + parent.offsetWidth) {
// means is in bounds
this.next();
return;
if (target) {
const parent = this.$refs.scroller;
const { marginLeft, marginRight } = getComputedStyle(target);
const targetWidth = target.offsetWidth + parseInt(marginLeft) + parseInt(marginRight);
if (target.offsetLeft + targetWidth < parent.scrollLeft + parent.offsetWidth) {
// means is in bounds
this.next();
return;
}
}
}
this.scrollToIndex();
Expand All @@ -115,15 +117,16 @@ export default class SliderElement extends TemplateElement {
if (this.autoSelect && this.canSlide) {
//check if element is already visible
const target = this.items[this.selectedIndex];
const { marginLeft } = getComputedStyle(target);
const parent = this.$refs.scroller;
if (target.offsetLeft - parseInt(marginLeft) > parent.scrollLeft) {
// means is still in viewport
this.previous();
return;
if (target) {
const { marginLeft } = getComputedStyle(target);
const parent = this.$refs.scroller;
if (target.offsetLeft - parseInt(marginLeft) > parent.scrollLeft) {
// means is still in viewport
this.previous();
return;
}
}
}

this.scrollToIndex();
}

Expand All @@ -150,6 +153,8 @@ export default class SliderElement extends TemplateElement {
this.startScrollEndTimer();
}
const target = this.items[this.selectedIndex];
if (!target) return;

const parent = this.$refs.scroller;
const parentWidth = parent.offsetWidth;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export const variableWidthEdgeFocusVariant = () => html`
</slider-element>
`;

export const noItemsVariant = () => html`
<slider-element arrows="false"></slider-element>
`;

class RenderingElement extends TemplateElement {
constructor() {
super({ shadowRender: false, deferUpdate: true });
Expand Down
Loading