livechat 0.4.7 → 0.4.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09c824179376138fe658faa40d6cc57949c642e10f42338d442152d50ab4db38'
4
- data.tar.gz: 0477a0b2e15986595aec854184f0d97ab72dc92fd8ced2738145cc985589490c
3
+ metadata.gz: 7f0dd913b9f9ac88756a298d2ad57cf69c78d3f8bf31c08941171a6d13626a16
4
+ data.tar.gz: 1148803aaf1b0d465afd5526ee6196d0814f23f0a3c75d4f9a7cfbd3ba96f6ee
5
5
  SHA512:
6
- metadata.gz: f356b2a55640050e11d295ccded406fe4f4698543241ed04bf0754ff9a11b079a566e889391c04bb4b9558fc5989c7a52fcd4a7fa36627ef506a0479e4e419c9
7
- data.tar.gz: fd1edc5d3a0cd36fd8f03cf8ac7946d5615249e1d8da69bc43a9e6d2393aa61a1bde6c39ae65acc71aba70e21a26c80e60fb089433e4a87b0c654eff4c1c0266
6
+ metadata.gz: 8eff7b6fff9df34b825dd647d41eabc4e415572bd5dd282465f52de3e2ac4fa3ee648a6123b426dc67615f064d82e3354762b0cc9103ea9d724d251de5e769c8
7
+ data.tar.gz: 57905952ca50aaa60b2103577ab54f6ee433f0729329ee5ea999e7a4bade5100a9e585ce9702842857962209f3b63369db9dde0b03358a723d4a9bb960e48251
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.8
4
+
5
+ - A conversation with image attachments now opens scrolled to the bottom, not
6
+ mid-thread. Images load after the initial scroll and grow the thread, so both
7
+ the inbox and the widget now re-pin to the bottom as each image loads (and
8
+ the inbox keeps you pinned until you scroll up). Fixes threads with
9
+ screenshots opening somewhere in the middle.
10
+
3
11
  ## 0.4.7
4
12
 
5
13
  - The inbox reply composer now matches the visitor widget: one bordered box
@@ -130,7 +130,21 @@
130
130
  var thread = document.getElementById("thread");
131
131
  if (!thread) return;
132
132
 
133
- thread.scrollTop = thread.scrollHeight;
133
+ // Stick to the bottom until the agent scrolls up. Images (screenshots and
134
+ // attachments) finish loading after DOMContentLoaded and grow the thread,
135
+ // so a single scroll-to-bottom now would land mid-thread once they expand
136
+ // — re-pin as each image loads and once the page has fully loaded.
137
+ var stick = true;
138
+ var keepBottom = function () { if (stick) thread.scrollTop = thread.scrollHeight; };
139
+ thread.addEventListener("scroll", function () {
140
+ stick = thread.scrollHeight - thread.scrollTop - thread.clientHeight < 80;
141
+ });
142
+ keepBottom();
143
+ var images = thread.querySelectorAll("img");
144
+ for (var i = 0; i < images.length; i++) {
145
+ if (!images[i].complete) images[i].addEventListener("load", keepBottom);
146
+ }
147
+ window.addEventListener("load", keepBottom);
134
148
 
135
149
  var replyBox = document.querySelector(".reply textarea");
136
150
  var latest = parseInt(thread.getAttribute("data-latest"), 10) || 0;
@@ -204,6 +218,7 @@
204
218
  img.src = att.url;
205
219
  img.alt = att.name;
206
220
  img.loading = "lazy";
221
+ img.addEventListener("load", keepBottom); // a live image grows the thread
207
222
  link.appendChild(img);
208
223
  } else {
209
224
  link.className = "att-file";
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Livechat
4
- VERSION = '0.4.7'
4
+ VERSION = '0.4.8'
5
5
  end
@@ -681,6 +681,9 @@
681
681
  img.src = att.url;
682
682
  img.alt = att.name;
683
683
  img.loading = "lazy";
684
+ // The image loads after its bubble is placed and grows the panel —
685
+ // re-pin to the bottom so a just-arrived image stays in view.
686
+ img.addEventListener("load", scrollToBottom);
684
687
  link.appendChild(img);
685
688
  } else {
686
689
  link.className = "lvc-att-file";
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livechat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov