Skip to content

Commit 537461f

Browse files
Christopher Asfourfacebook-github-bot
Christopher Asfour
authored andcommitted
Establish ZoomableEventListener to detect start and finish zooming events
Summary: ## Context - We want to test Pinch to Zoom on reels ads, in order to bring more consistency across the app. - This feature is already launched on reels organic and home feed, and is being tested on stories too. ## This Diff - In `ClipsItemGestureDetector`, when an `onTouchEvent()` is received, the `zoomableGestureController` calls `onTouch`, which then calls `listeners.any { it.onTouchEvent(event) } ` in `ZoomableTouchGestureListener`. This ends up calling the zoomableTouchListener overriden onTouchEvent function within LithoZoomableController, and inside this it ends up calling the necessary functions to start zoom methods in ZoomableViewBaseController - We now want to do the reverse. - To notify `ClipsItemComponent` when zooming starts and finishes, we will use a callback interface. We will create a new interface ` ZoomableEventListener`with two methods: onZoomStarted() and onZoomFinished() within the `ZoomableViewBaseController`. Reviewed By: fbcbl Differential Revision: D68932919 fbshipit-source-id: 066a9d7c1f48c72479cfd66d0501fef050324b7b
1 parent 4fb7ab4 commit 537461f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: litho-zoomable/src/main/kotlin/com/facebook/litho/widget/zoomable/ZoomableComponent.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ import com.facebook.rendercore.primitives.LayoutBehavior
3838
import com.facebook.rendercore.primitives.LayoutScope
3939
import com.facebook.rendercore.primitives.PrimitiveLayoutResult
4040
import com.facebook.rendercore.primitives.ViewAllocator
41+
import com.facebook.rendercore.zoomable.ZoomableViewBaseController
4142
import kotlin.math.max
4243

4344
@ExperimentalLithoApi
4445
class ZoomableComponent(
4546
private val zoomableTouchGestureListener: ZoomableTouchGestureListener? = null,
47+
private val zoomableEventListener: ZoomableViewBaseController.Listener? = null,
4648
private val style: Style = Style,
4749
private val child: () -> Component
4850
) : PrimitiveComponent() {
@@ -83,14 +85,18 @@ class ZoomableComponent(
8385
MountBehavior(ALLOCATOR) {
8486
bindToRenderTreeView(state = state) { renderTreeView }
8587

86-
bind(lithoZoomableController) { content ->
88+
bind(lithoZoomableController, zoomableEventListener) { content ->
8789
lithoZoomableController.bindTo(content)
8890
zoomableTouchGestureListener.addZoomableTouchListener(
8991
lithoZoomableController.zoomableTouchListener)
92+
zoomableEventListener?.let { lithoZoomableController.addZoomableEventListener(it) }
9093

9194
onUnbind {
9295
zoomableTouchGestureListener.removeZoomableTouchListener(
9396
lithoZoomableController.zoomableTouchListener)
97+
zoomableEventListener?.let {
98+
lithoZoomableController.removeZoomableEventListener(it)
99+
}
94100
lithoZoomableController.unbind()
95101
}
96102
}

0 commit comments

Comments
 (0)