Get direction (compass) with two longitude/latitude points

O forgot to say I found the answer eventually. The application is to determine compass direction of a transit vehicle and its destination. Essentially, fancy math for acquiring curvature of Earth, finding an angle/compass reading, and then matching that angle with a generic compass value. You could of course just keep the compassReading and apply … Read more

Detecting the scrolling direction in the adapter (up/down)

Assign an OnScrollListener to your ListView. Create a flag which indicates whether the user is scrolling up or down. Set an appropriate value to the flag by checking if the current first visible item position equals to more or less than the previous first visible item position. Put that check inside onScrollStateChanged(). Sample code: private … Read more

right-to-left (RTL) in flutter

you have two choices : 1. force a locale ( and direction ) on all devices — method 1: with localization add flutter_localizations package to your pubspec.yml dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter then import ‘package:flutter/material.dart’; import ‘package:flutter_localizations/flutter_localizations.dart’; MaterialApp( localizationsDelegates: [ GlobalCupertinoLocalizations.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], supportedLocales: [ Locale(“fa”, “IR”), // OR Locale(‘ar’, ‘AE’) OR … Read more

How to recognize swipe in all 4 directions

You need to have one UISwipeGestureRecognizer for each direction. It’s a little weird because the UISwipeGestureRecognizer.direction property is an options-style bit mask, but each recognizer can only handle one direction. You can send them all to the same handler if you want, and sort it out there, or send them to different handlers. Here’s one … Read more

How to detect scroll direction

I managed to figure it out in the end, so if anyone is looking for the answer: //Firefox $(‘#elem’).bind(‘DOMMouseScroll’, function(e){ if(e.originalEvent.detail > 0) { //scroll down console.log(‘Down’); }else { //scroll up console.log(‘Up’); } //prevent page fom scrolling return false; }); //IE, Opera, Safari $(‘#elem’).bind(‘mousewheel’, function(e){ if(e.originalEvent.wheelDelta < 0) { //scroll down console.log(‘Down’); }else { //scroll … Read more