nativescript-drawingpad icon indicating copy to clipboard operation
nativescript-drawingpad copied to clipboard

SignaturePad inside ScrollView

Open droopram opened this issue 7 years ago • 4 comments

I have the following XML (not exactly but the gist is the same):

<ScrollView>
    <StackLayout #form>
        <ActivityIndicator 
                [busy]="isLoading" 
                [visibility]="isLoading ? 'visible' : 'collapsed'" 
                row="1" 
                horizontalAlignment="center" 
                verticalAlignment="center"></ActivityIndicator>
        <StackLayout #container [class.visible]="!isLoading">
                <DrawingPad id="1" height="120" penColor="#212F3D" penWidth="3" class="drawingpad"></DrawingPad>
        <!-- Lots of elements -->
        </StackLayout>
    </StackLayout>
</ScrollView>

When I try to draw vertical lines, the scrollview takes over and scrolls the page instead of drawing within the pad.. Any idea's on how to fix this? Thanks!

droopram avatar Jun 19 '17 13:06 droopram

Having this same issue, did you figure out a workaround?

lukeramsden avatar Sep 05 '17 14:09 lukeramsden

@lukeramsden you could ty to set isUserInteractionEnabled: <ListView isUserInteractionEnabled="false" items="{{ source }}" loaded="onLoaded" itemLoading="onItemLoading" itemTap="onItemTap"> as described here https://github.com/NativeScript/NativeScript/issues/2892 i had the same issue

krisidmisso avatar Mar 23 '18 10:03 krisidmisso

@droopram

Try this out:

<ScrollView  :isScrollEnabled="allowScrolling">

Then create the data property:

data() {
    return {
      allowScrolling: true
    };
  }

This will allow scrolling by default.

Then pass the allowScrolling value as a prop to your child component and watch the child component: (I'm using single file components, you may not need this)

:scrolling="allowScrolling"
v-on:allowScrolling="allowScrolling = $event"

Inside your child component, add a button to toggle scrolling on and off

<Button text="Tap to Sign" @tap="toggleScrolling(event)"/>

Finally, add a method to emit the new value to the parent component:

 toggleScrolling(event) {
      this.$emit("allowScrolling", !this.scrolling);
    }

Hopefully this gets you closer to a workable solution.

mjbonanno avatar Dec 31 '18 22:12 mjbonanno

This is my workaround (Nativescript-Vue)

<ScrollView ref="scrollView>
    <StackLayout>
        <DrawingPad @touch="onSignatureTouch" />
    </StackLayout>
</ScrollView>
onSignatureTouch(args) {
    if (args.android) return;
    if (args.action === "down") this.$refs.scrollView.nativeView.ios.scrollEnabled = false;
    else if (args.action === "up") this.$refs.scrollView.nativeView.ios.scrollEnabled = true;
}

tommag21 avatar Apr 09 '20 20:04 tommag21