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

Changes in a deep copy of an object in a child component are directly reflected in the parent object in VueJS

Let's begin by discussing the layout. I have a page dedicated to showcasing information about a specific company, with a component Classification.vue. This component displays categories of labels and the actual labels assigned to the current company. ...

Attempting to showcase information in React

Having recently delved into React, I am attempting to display data (within a bootstrap modal) from MongoDB to React using an axios ajax request. Postman indicates everything is correct. However, React throws an error stating "TypeError: this.state.reviews. ...

Utilizing JQuery for retrieving a filename

I have a unique file upload button on my website. To provide the user with visual feedback about their chosen file, I modify the html of a div to display the file name. My jquery code is as follows: $("input[type=file]").change(function() { var filen ...

Unpredictable preset inline styles for HTML input elements

While developing a full-stack MERN application, I encountered an unusual issue when inspecting my React UI in Chrome DevTools. If any of these dependencies are playing a role, below are the ones installed that might be contributing to this problem: Tail ...

Issue with getStaticProps functionality on Vercel seems to be persisting

UPDATE: I realize now that my mistake was calling my own API instead of querying the MongoDB database directly in getStaticProps(). I have made the necessary changes: export async function getStaticProps() { await dbConnect(); const user = await User.find ...

Unexpected values being returned by Javascript/jQuery variables

Struggling with understanding scope in JavaScript, like many others before me. It can be quite challenging to navigate through the code at times. I've reviewed previous discussions on this topic, but I'm still having trouble applying it to my spe ...

Sorting information in the React Native Section List

Working with React Native's SectionList and filtering data: data: [ { title: "Asia", data: ["Taj Mahal", "Great Wall of China", "Petra"] }, { title: "South America", data: ["Machu Picchu", "Christ the Redeemer", "C ...

Using Node to parse XLSX files and generate JSON data

Hello, I am currently utilizing the js-xlsx package which can be found at this link. My inquiry is how to successfully parse an xlsx file with merges and convert it into JSON format. You can view what the excel sheet looks like here. Ultimately, the JSON o ...

Exploring the magic of Hover effects using CSS and JQuery

I am exploring ways to enhance the display of an element when hovering over it. I have implemented a button and my objective is for the first click to activate the hover effect, while the second click will reset it. However, I am facing an issue where the ...

Having trouble accessing the downloaded file from S3 using Angular and NodeJS

Currently, I am facing an issue while attempting to download a jpg image from amazon S3 using the NodeJs SDK. Although I can successfully retrieve the file object on the backend, encountering difficulties arises when trying to create a blob object and down ...

Exploring the capabilities of xhr2 using pure javascript

Currently, I am attempting to utilize xhr2 in order to read through a json file. Despite my efforts in researching various methods to accomplish this task, none have proved successful thus far. The function featured below my require statements is the one t ...

Join the geomarkers in two datasets using connecting lines

I am currently developing a leaflet.js map incorporating two distinct sets of JSON data layers stored as js-files. The first dataset comprises the geographical locations of various newsrooms along with their respective IDs, while the second dataset contai ...

Tips for repositioning a node element as the first child within its parent element

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id='parent'> <div>B</div> <div>C</div> <div onload='this.parentNode.prependChild();'>A&l ...

After using JSON.parse(), backslashes are still present

Recently Updated: Received server data: var receivedData = { "files":[ { "filename": "29f96b40-cca8-11e2-9f83-1561fd356a40.png", "cdnUri":"https://abc.s3.amazonaws.com/" ...

Is there a possible method to obtain a smartphone number from a website?

Seeking a solution to retrieve the phone number of a device using HTML 5, JavaScript, or similar technology. Recently, I successfully obtained the coordinates of the device by incorporating the following JavaScript code: <!DOCTYPE html> <html> ...

Unveiling the Mystery: Uncovering the Selected Item in Ionic Checkboxes

I am trying to implement a feature in Ionic checkboxes where I can get the selected item when a user checks one or more checkboxes. Specifically, I want to identify which books the user has selected. Below are snippets of my code: <ion-item ng ...

Transferring data only once specific agreements have been fulfilled

Imagine having a file with specific promises that, when executed sequentially, create an input file called input.txt. // prepareInput.js var step1 = function() { var promise = new Promise(function(resolve, reject) { ... }); return p ...

I do not prefer output as my optimal choice

My preference is to create drill down buttons rather than focusing on output. Currently, the output appears as: The content of index.html is as follows: <html>  <head> <script type="text/javascript" src="http://ajax.googleapis.com/ ...

Avoiding duplication of prints in EJS template files

In my EJS code, I have created a loop to fetch the total amount of items from the database. Here is my current code: <h2>Summary</h2> <% if(typeof items.cart!=="undefined"){ var amount = 0; %> <% i ...

Calling Node Express request inside a GET route

I am currently utilizing nodejs as an intermediary layer between my public website and an internal server within our network. Through the use of express.js, I have created a basic REST api where the endpoint should trigger a request call to a webservice a ...