From f443f3792d0371355055ccf0c00c0298c6df6bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Wed, 23 Sep 2015 16:24:52 +0200 Subject: [PATCH] Implement events through for container when !visibleContent --- RNGL/GLCanvas.h | 1 + RNGL/GLCanvas.m | 15 ++++++++++++++- RNGL/GLCanvasManager.m | 1 + src/View.js | 6 +++--- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/RNGL/GLCanvas.h b/RNGL/GLCanvas.h index f53d3f8..a4ffb00 100644 --- a/RNGL/GLCanvas.h +++ b/RNGL/GLCanvas.h @@ -7,6 +7,7 @@ @property (nonatomic) BOOL opaque; @property (nonatomic) BOOL autoRedraw; @property (nonatomic) BOOL eventsThrough; +@property (nonatomic) BOOL visibleContent; @property (nonatomic) NSNumber *nbContentTextures; @property (nonatomic) NSNumber *renderId; @property (nonatomic) NSArray *imagesToPreload; diff --git a/RNGL/GLCanvas.m b/RNGL/GLCanvas.m index 25ecba7..aa46941 100644 --- a/RNGL/GLCanvas.m +++ b/RNGL/GLCanvas.m @@ -131,7 +131,20 @@ NSString* srcResource (id res) - (void)setEventsThrough:(BOOL)eventsThrough { - self.userInteractionEnabled = !eventsThrough; + _eventsThrough = eventsThrough; + [self updateUIE]; +} + +-(void)setVisibleContent:(BOOL)visibleContent +{ + _visibleContent = visibleContent; + [self updateUIE]; +} + +- (void) updateUIE +{ + self.userInteractionEnabled = !(_eventsThrough); + self.superview.userInteractionEnabled = !(_eventsThrough && !_visibleContent); } - (void)setData:(GLData *)data diff --git a/RNGL/GLCanvasManager.m b/RNGL/GLCanvasManager.m index 816409c..4c598f6 100644 --- a/RNGL/GLCanvasManager.m +++ b/RNGL/GLCanvasManager.m @@ -22,6 +22,7 @@ RCT_EXPORT_VIEW_PROPERTY(nbContentTextures, NSNumber); RCT_EXPORT_VIEW_PROPERTY(opaque, BOOL); RCT_EXPORT_VIEW_PROPERTY(autoRedraw, BOOL); RCT_EXPORT_VIEW_PROPERTY(eventsThrough, BOOL); +RCT_EXPORT_VIEW_PROPERTY(visibleContent, BOOL); RCT_EXPORT_VIEW_PROPERTY(data, GLData); RCT_EXPORT_VIEW_PROPERTY(renderId, NSNumber); RCT_EXPORT_VIEW_PROPERTY(imagesToPreload, NSArray); diff --git a/src/View.js b/src/View.js index 16e5e62..99e2ba9 100644 --- a/src/View.js +++ b/src/View.js @@ -11,10 +11,10 @@ const { const GLCanvas = requireNativeComponent("GLCanvas", null); -const renderVcontent = function (width, height, id, children, visibleContent) { +const renderVcontent = function (width, height, id, children, { visibleContent }) { const childrenStyle = { position: "absolute", - top: visibleContent ? 0 : height, + top: visibleContent ? 0 : height, // as a workaround for RN, we offset the content so it is not visible but still can be rasterized left: 0, width: width, height: height, @@ -32,7 +32,7 @@ const renderVGL = function (props) { />; }; -const renderVcontainer = function (width, height, contents, renderer, style) { +const renderVcontainer = function ({ style, width, height }, contents, renderer) { const parentStyle = { position: "relative", ...style, -- 2.26.2