@dr33m/react-native-readium 5.0.0-rc.23 → 5.0.0-rc.24
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.
|
@@ -42,6 +42,11 @@ abstract class BaseReaderFragment : Fragment() {
|
|
|
42
42
|
// TTS
|
|
43
43
|
private var ttsManager: TTSManager? = null
|
|
44
44
|
|
|
45
|
+
// True while the user has an active text selection.
|
|
46
|
+
// applyDecorations injects JS into the EPUB WebView; doing so while the user
|
|
47
|
+
// is dragging selection handles causes the selection to jump or reset.
|
|
48
|
+
private var isUserSelecting = false
|
|
49
|
+
|
|
45
50
|
// Track active decoration listeners to avoid duplicates
|
|
46
51
|
private val activeDecorationGroups = mutableSetOf<String>()
|
|
47
52
|
|
|
@@ -275,6 +280,7 @@ abstract class BaseReaderFragment : Fragment() {
|
|
|
275
280
|
|
|
276
281
|
private fun applyTTSDecoration(locator: Locator) {
|
|
277
282
|
if (!isNavigatorReady) return
|
|
283
|
+
if (isUserSelecting) return // skip DOM update while user drags selection handles
|
|
278
284
|
val decorableNavigator = navigator as? DecorableNavigator ?: return
|
|
279
285
|
// applyDecorations is suspend in Readium 3.x — must be called from a coroutine.
|
|
280
286
|
// viewLifecycleOwner.lifecycleScope dispatches to Dispatchers.Main, matching
|
|
@@ -344,6 +350,10 @@ abstract class BaseReaderFragment : Fragment() {
|
|
|
344
350
|
val currentLocator = currentSelection?.locator
|
|
345
351
|
val currentText = currentLocator?.text?.highlight
|
|
346
352
|
|
|
353
|
+
// Keep the guard flag in sync so TTS decoration skips DOM updates
|
|
354
|
+
// while the user is dragging selection handles.
|
|
355
|
+
isUserSelecting = currentLocator != null
|
|
356
|
+
|
|
347
357
|
// Check if selection has changed
|
|
348
358
|
val hasChanged = when {
|
|
349
359
|
previousSelection == null && currentLocator == null -> false
|