@konfuzio/document-validation-ui 0.2.1-dev.1 → 0.2.1-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konfuzio/document-validation-ui",
3
- "version": "0.2.1-dev.1",
3
+ "version": "0.2.1-dev.2",
4
4
  "repository": "https://github.com/konfuzio-ai/document-validation-ui",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -1,10 +1,6 @@
1
1
  <template>
2
2
  <div id="scrolling-document">
3
- <div
4
- ref="scrollingDocument"
5
- v-scroll.immediate="updateScrollBounds"
6
- class="scrolling-document"
7
- >
3
+ <div ref="scrollingDocument" class="scrolling-document">
8
4
  <transition :name="searchEnabled ? 'slide-down' : 'slide-up'">
9
5
  <SearchBar v-if="searchEnabled" />
10
6
  </transition>
@@ -114,6 +110,7 @@ export default {
114
110
  this.$refs.scrollingDocument.scroll(scrollX, scrollY);
115
111
  },
116
112
  handleScroll() {
113
+ this.updateScrollBounds();
117
114
  if (this.pages.length === 1) return;
118
115
 
119
116
  this.isScrolling = true;
@@ -1,9 +1,8 @@
1
1
  <template>
2
2
  <div id="document-pages" ref="documentThumbnails">
3
- <div v-if="selectedDocument">
3
+ <div v-if="selectedDocument" ref="docPage">
4
4
  <div
5
5
  v-for="page in selectedDocument.pages"
6
- ref="docPage"
7
6
  :key="page.id"
8
7
  :class="[
9
8
  'document-thumbnail',
@@ -76,21 +75,12 @@ export default {
76
75
  },
77
76
  watch: {
78
77
  currentPage(newPage) {
79
- if (!newPage) return;
78
+ if (!newPage || newPage == this.thumbnailClicked) return;
80
79
 
81
80
  // handle thumbnail selection when scrolling the document
82
81
  this.scrollToThumbnail(newPage);
83
82
  },
84
83
  },
85
- mounted() {
86
- const scrollingPage = document.querySelector(".scrolling-document");
87
-
88
- if (scrollingPage) {
89
- scrollingPage.addEventListener("scroll", () => {
90
- this.scrollToThumbnail();
91
- });
92
- }
93
- },
94
84
 
95
85
  methods: {
96
86
  /* Change page if not the currently open and not in modal */
@@ -109,17 +99,10 @@ export default {
109
99
 
110
100
  scrollToThumbnail(page) {
111
101
  // select only the active thumbnail
112
- const selectedPage = this.$refs.docPage.filter((image) =>
113
- image.className.includes("selected")
114
- );
115
-
116
- if (page == this.thumbnailClicked) {
117
- this.thumbnailClicked = null;
118
- }
119
-
120
- if (!this.thumbnailClicked && selectedPage && selectedPage[0]) {
121
- selectedPage[0].scrollIntoView();
122
- }
102
+ this.thumbnailClicked = null;
103
+ this.$refs.docPage.children[page - 1].scrollIntoView({
104
+ behavior: "smooth",
105
+ });
123
106
  },
124
107
  },
125
108
  };
@@ -270,7 +270,11 @@ const actions = {
270
270
  commit("SET_SCALE", autoScale);
271
271
  break;
272
272
  case "all": {
273
- const widthScale = getters.pageWidthScale(elementsWidth, client.width, viewport.width);
273
+ const widthScale = getters.pageWidthScale(
274
+ elementsWidth,
275
+ client.width,
276
+ viewport.width
277
+ );
274
278
  commit("SET_SCALE", widthScale);
275
279
  break;
276
280
  }