Comments (4)
Yes and when tapping on the "container" was causing it to tilt was well. Is there a feature to set tap to false?
Currently, Quick Tap cannot gracefully handle gesture competition.
Tilt can only be triggered by moving and long-pressing.
So in your instance, how would the FAB be off screen upon load? Then you can tilt to reveal it?
Upgrading to version 2.0.4
You can try this sample:
Code sample
import 'package:flutter/material.dart';
import 'package:flutter_tilt/flutter_tilt.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Tilt Demo',
theme: ThemeData(
primarySwatch: Colors.brown,
),
home: const TiltDemo(),
);
}
}
class TiltDemo extends StatefulWidget {
const TiltDemo({super.key});
@override
State<TiltDemo> createState() => _TiltDemoState();
}
class _TiltDemoState extends State<TiltDemo> {
int _counter = 0;
bool enableGestureTouch = true;
bool enableGestureHover = true;
bool enableGestureSensors = true;
Offset position = const Offset(-25, -25);
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFFFFFFF),
body: Center(
child: Tilt(
borderRadius: BorderRadius.circular(24),
tiltConfig: TiltConfig(
angle: 20,
enableRevert: false,
enableSensorRevert: false,
enableGestureSensors: enableGestureSensors,
enableGestureHover: enableGestureHover,
enableGestureTouch: enableGestureTouch,
),
lightConfig: const LightConfig(
minIntensity: 0.1,
),
shadowConfig: const ShadowConfig(
minIntensity: 0.05,
maxIntensity: 0.4,
offsetFactor: 0.08,
minBlurRadius: 10,
maxBlurRadius: 15,
),
childLayout: ChildLayout(
inner: [
Positioned(
top: 200,
child: TiltParallax(
size: const Offset(-20, -20),
child: Text(
'$_counter',
style: const TextStyle(fontSize: 20),
),
),
),
Positioned(
bottom: position.dy,
right: position.dx,
child: TiltParallax(
size: const Offset(35, 35),
child: Listener(
onPointerDown: (e) {
setState(() {
enableGestureTouch = false;
enableGestureHover = false;
enableGestureSensors = false;
});
},
onPointerMove: (event) {
setState(() {
position -= event.delta;
});
},
onPointerUp: (event) {
setState(() {
enableGestureTouch = true;
enableGestureHover = true;
enableGestureSensors = true;
});
},
child: SizedBox(
width: 50,
height: 50,
child: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
),
),
),
],
),
// onGestureMove:
// (TiltDataModel tiltDataModel, GesturesType gesturesType) {
// print('--- onGestureMove ---');
// print(tiltDataModel.areaProgress);
// print(gesturesType.name);
// },
// onGestureLeave:
// (TiltDataModel tiltDataModel, GesturesType gesturesType) {
// print('--- onGestureLeave ---');
// print(tiltDataModel.areaProgress);
// print(gesturesType.name);
// },
child: const MyHomePage(title: 'Flutter Tilt Demo'),
),
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return SizedBox(
width: 250,
height: 450,
child: Scaffold(
backgroundColor: const Color(0x206D6E6F),
appBar: AppBar(
title: Text(
widget.title,
style: const TextStyle(fontSize: 18),
),
),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'You have pushed the button this many times',
style: TextStyle(fontSize: 10),
),
],
),
),
),
);
}
}
from flutter_tilt.
Hi~ @jtkeyva, Thanks for the suggestion.
Is this the effect you need?
- Tapping when
enableRevert
orenableSensorRevert
is false will not cause tilt. - FAB can be moved around and the rest of the content doesn't tilt with it (hypothetical example, mainly showing the competition of gestures).
Screenrecorder-2023-09-20-20-35-22-774.mp4
from flutter_tilt.
Hi thanks. Yes and when tapping on the "container" was causing it to tilt was well. Is there a feature to set tap to false?
That is a cool example. It also shows a feature that i wanted to try... have content off screen that becomes visible when you tilt or swipe to reveal. So in your instance, how would the FAB be off screen upon load? Then you can tilt to reveal it?
Very cool!
from flutter_tilt.
@AmosHuKe thank you! that gives me a good head start :) and yes, tapping bug is now fixed :)
from flutter_tilt.
Related Issues (10)
- [Feature] 可以增加重力感应版本的嘛?Sensors HOT 1
- Tilt & Hold Position? Or Tilt to Pan? HOT 5
- After use, the mobile phone fever is serious, please check what is the reason HOT 4
- What is the reason for the rapid heating of the mobile phone after use? HOT 2
- This prompt appears on iOS HOT 2
- [Feature] Disable Features on Low Power Mode HOT 1
- [Feature request] Need to set tilt programmatically. HOT 2
- [Feature request] Ability to have light and shadow for png images with transparent layers. HOT 6
- [Bug report] Black bars when using in mobile browser. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_tilt.