I am looking for a sample code for Tizen that allows scrolling of a <div> element using the bezel

Seeking a functional web application in Tizen that can scroll a div using the rotating bezel mechanism.

I have dedicated several hours to getting it to work without success. I keep revisiting the same resources for the past three days:

View Link 1 View Link 2

Despite my efforts, the solution seems elusive. While I managed to adjust text on another template app by rotating the bezel on my Gear S3, scrolling remains a challenge. It appears that my struggle lies in selecting the correct DOM elements or configuring event listeners for the scroller feature.

Referencing the provided links, here is an example code snippet that showcases my attempt:

// JavaScript code goes here
// CSS styles go here
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Description here"/>

    <title>Title Here</title>

    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script src="js/main.js"></script>
</head>

<body>


<div class="ui-page ui-page-active" id="main">
   <header class="ui-header">
      <h2 class="ui-title">Header Title</h2>
   </header>
   <div class="ui-content">
       // Content goes here
   </div>
   <!--Popup-->
   <div id="popup" class="ui-popup">
      <div class="ui-popup-content">
         // Popup content here
      </div>
      <div class="ui-popup-footer ui-bottom-button">
         <a id="btnPopup-cancel" href="#" class="ui-btn" data-rel="back">Cancel</a>
      </div>
   </div>
</div>


</body>
</html>

Answer №1

Your code is not functioning properly due to the event listener for "pagebeforeshow" being added too late.

Instead of this:

window.onload = function () {
 ...
};

try:

window.addEventListener("DOMContentLoaded", function () {
 ...
});

Also, ensure that your main.js file is placed above the TAU library.

    <link href="tau/wearable/theme/default/tau.css" rel="stylesheet" />
    <link href="tau/wearable/theme/default/tau.circle.css" rel="stylesheet" />
    <link href="style.css" rel="stylesheet" />
    <link href="css/style.circle.css" rel="stylesheet" />
    <script src="js/main.js"></script>
    <script src="tau/wearable/js/tau.js"></script>
</head>

If you encounter any issues, please consider creating an issue in our project on Github (https://github.com/Samsung/TAU) for further improvement.

Answer №2

Appreciate the help! Although I couldn't make it work in this way (maybe there were other issues), I did find a different solution that worked for me:

(function() {

var page = document.getElementById('main');  // <div id="main" class="container">

document.getElementById('main').setAttribute('tizen-circular-scrollbar', '');

function rotaryDetentHandler (e) {
    var direction = e.detail.direction;

if (direction === "CW") {
page.scrollTop += 50;
} 
else if (direction === "CCW") {
page.scrollTop -= 50;
}

}

document.addEventListener('rotarydetent', rotaryDetentHandler);
//add eventListener for tizenhwkey
document.addEventListener('tizenhwkey', function(e) {
    if (e.keyName === "back") {
        try {
            tizen.application.getCurrentApplication().exit();
        } catch (ignore) {
        }
    }
});


}());
html,
body {
    width: 360px;
    height: 360px;
    margin: 0;
    padding: 0;
    background-color: #fff;
}

.container {
    background-color: #000;
    color: #fff;
    height: 100%;
    width: 100%;
    text-align: center;
    overflow-y: auto;
}

#news-view {
    background-color: #fff;
    color: #000;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Tizen Wearable basic template generated by Samsung Wearable Web IDE"/>

    <title>Tizen Wearable Web IDE - Tizen Wearable - Tizen Wearable basic Application</title>

    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script src="js/main.js"></script>
</head>

<body>



<div id="main" class="container">

      
    <p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>
<p>Hello World!!!!!</p>
<p>Hello World!</p>        
            
</div>


</body>
<script src="js/main.js"></script>

</html>

Answer №3

Previously, you utilized events like "pagebeforeshow", "popup show", and "popup hide" in your first example. These events are tailored for the TAU framework and JQueryMobile, leading me to believe that you were implementing TAU in your application. This could explain why the initial solution did not yield the desired outcome.

In contrast, your most recent solution focuses on simply scrolling content within a web application without incorporating the TAU library.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps can I take to modify the class of a button once it has been clicked using JQuery?

Currently, I am experimenting with Jquery to dynamically change the classes of bootstrap buttons when they are clicked. However, I have encountered a limitation while using toggleClass. The issue is that I am only able to toggle between two classes, whic ...

To access a restricted selection of images stored in Firebase

Is there a way to load additional images from Firebase by clicking a button? I created a function that looks like this: onLoadMore() { if (this.all.length > 1 ) { const lastLoadedPost = _.last(this.all); const lastLoadedPostKey = lastLoadedP ...

Initiate requests to external servers from a NodeJS backend

My NextJS application seamlessly collaborates with a NodeJS server to act as the front end of my innovative three-tier architecture. 'use client'; import FormControl from '@mui/material/FormControl'; import InputLabel from '@mui/m ...

A Step-by-Step Guide to Setting Up and Utilizing V-Calendar in Vue.js

I am currently trying to incorporate the V-Calendar library into my Vuetify application. Up until now, the app was working fine, but I seem to have hit a roadblock with the correct installation of the V-Calendar library. Although no error messages are bei ...

Utilizing JSX within this.state results in it being displayed as plain text when rendered

Currently, I am dynamically rendering a list of elements and I need to insert other elements in front of them based on key-value pairs. I want to utilize <sup></sup> tags for these elements, but they are appearing as plain text rather than sup ...

Show react-card-flip children conditionally based on a button, otherwise display one frontside and two backsides

Is it possible to achieve the following functionality using the react-flip-package? I have a card with two buttons on the front side. When I click one button, I want the card to flip to one backside, and when I click the other button, I want it to flip to ...

ESLint refuses to be turned off for a particular file

I am in the process of creating a Notes.ts file specifically for TypeScript notes. I require syntax highlighting but do not want to use eslint. How can I prevent eslint from running on my notes file? Directory Structure root/.eslintignore root/NestJS.ts r ...

Vue project encounters disappeared DOM element

I'm currently developing a code typer, but I've encountered an issue where the element inexplicably turns into Null. Despite having some experience with Vue from my previous project on Django/Python at (live preview), I find myself struggling to ...

Using Vue.js to Authenticate Users with JWT Tokens Sent in Registration Emails

Hey everyone, I could really use some assistance with JWT tokens. I created a registration form using Vue.js and sent the data to the database using axios. Now, I need help figuring out how to save the token I receive in the confirmation email so that I ca ...

Ways to expand the `Array.prototype` from an external library in a Node.js environment

While enjoying my time on hackerrank with pure JavaScript, I decided to steer clear of extra arrays or math libraries, unlike the convenience of using python. My approach is robust, but now I'm considering utilizing sugar.js or underscore. I came acr ...

A guide on using jQuery-Tabledit and Laravel to efficiently update table rows

In Laravel, it is necessary to include the row ID in the request URL to update it, for example: http://localhost/contacts/16 The challenge arises when using jQuery-Tabledit, which requires a fixed URL during initialization on page load. Hence, the query ...

What is the process for importing the required dependencies for the maps module in react-svg-map?

Exploring interactive maps led me to discover the project react-svg-map. As I followed the example provided, a certain issue caught my attention: import Taiwan from "@svg-maps/taiwan"; The developers mentioned that they have separated the map&ap ...

Create a time of 00:19:59 using JavaScript

I am attempting to display a countdown timer that starts at 20 minutes in the format (00:20:00) using setInterval. Once the countdown is finished, it should display as (00:00:00), but I am having trouble achieving this. <body onload = "onloadFunc();" ...

Is it recommended to create model classes in React components?

Within the realms of React, the Flux architecture is utilized. According to https://reactjs.org/docs/thinking-in-react.html, React operates with two distinct models - namely, the state and props. There are recommendations provided for model management in ...

Adjusting the color of a cell based on its value

Currently, I am in the process of converting a CSV file to an HTML table by utilizing a tool available at . However, I am facing a challenge in modifying the background color of cells based on their values. I would greatly appreciate any help or guidance w ...

How do I retrieve the download URL for the file created using Python in my Heroku App?

After developing my Flask App, I uploaded several files to the Heroku filesystem. I'm aware that these files are removed every time the dyno restarts. Now, in my HTML/JavaScript frontend, I'd like to provide users with a download button for thes ...

Creating a flexible route path with additional query parameters

I am facing a challenge in creating a unique URL, similar to this format: http://localhost:3000/boarding-school/delhi-ncr However, when using router.push(), the dynamic URL is being duplicated like so: http://localhost:3000/boarding-school/boarding-school ...

Creating a private variable in Javascript is possible by using getter and setter functions to manage access to the

Is this the correct way to simulate a private variable? var C = function(a) { var _private = a + 1; // more code... Object.defineProperties(this, { 'privateProp': { get: function() { return _privat ...

Verify if a certain value exists in an array while using ng-if inside ng-repeat

Currently, I have a loop using ng-repeat that goes through a list of wines obtained from an API. Alongside this, there is an array variable containing all the IDs of wines that have been marked as favorites and retrieved from the database. My goal is to sh ...

What are the consequences of submitting a form to a different website through POST method?

Dealing with a CMS that does not offer an easy way to add a NodeJS route for handling form data can be quite challenging. I'm considering the following setup - would this be considered bad practice or unsafe? Server 1 (Ghost CMS) : www.domain.com &l ...