h5p / h5p-course-presentation

MIT License
54 stars 130 forks source link

How to show content step by step #125

Open tibaultbordeaux opened 4 years ago

tibaultbordeaux commented 4 years ago

Hi all,

I would like to partly hide the content of a slide with a drawn rectangle. The user than should be able to click on this rectangle and reveal the hidden content.

As I'm using h5p with WordPress I created a little WP-Plugin:

<?php
 function h5pmods_alter_scripts(&$scripts, $libraries, $embed_type) {
   $scripts[] = (object) array(
  'path' => '/myh5pmods.js',
  'version' => '?ver=1.0.0' // Cache buster
    );
  }
add_action('h5p_alter_library_scripts', 'h5pmods_alter_scripts', 10, 3);

and the javascript-file myh5pmods.js :

$(".h5p-shape-element.h5p-shape-rectangle").click(function() {
$(this).hide();
});

While the js-file is loading correctly (tested with a simple alert("")) the script is not working.

Who could give some hints for further debugging?

Thanks in advance!

ceibg commented 4 years ago

This is a subject for a broader functionality suggestion. There should be a way to click on a shape or button and to display hidden content on a slide and vice versa - to hide it. At the moment the only way to simulate this without extra tweaking h5p libraries is to add more slides and to use anchor - click on it and go to slide where the content you like to be seen is present.